Show TOC

Example: Using a Variable with Replacement from QueryLocate this document in the navigation structure


You want to insert the result of the query Top 5 Products as a variable into the query Sales - Calendar Year/Month.


  1. Select the characteristic Product and choose New Formula from the context menu. The New BW Variable wizard opens.
  2. Enter a description and a technical name for the new characteristic value variable.
  3. Select variable type Characteristic Value for field Type of Variable.
  4. Select processing type Replacement Path for field Processing By.
  5. Choose Next.
  6. Choose Query as the Replacement Rule.
  7. Choose the query Top 5 Products using the input help.
  8. You have not completed the definition of the variable. Choose Finish. The system creates the variable. The Variables Editor opens and you see the screen area that shows the properties of the variable.


You can now insert the variable into query Sales - Calendar Year/Month. This allows you to determine how the sales for these five top-selling products has developed month for month.


Every time you execute query Sales - Calendar Year/Month, query Top 5 Products is executed beforehand (hence the term "pre-query"). This can lead to longer runtimes. If you do not need to immediately execute the pre-query, we recommend that you use a variable, which represents a precalculated value set. This could be the case for example if you do not need to determine the top 5 products every time, because they only change on a monthly basis.