Variables in advanced formulas can be used to store data temporarily while the script is running, to avoid calculating the value repeatedly. This is the traditional concept referred to as a Local Variable or Virtual Variable Member. The virtual variable member will be stored independently and cannot be added to a dimension like a real dimension member. After defining a variable member for a certain dimension, you can use the variable member to store values only for that specific dimension.
Key Points
- Write the definition after the configuration settings and before all the instructions.
- Create a new name for a virtual variable member. Make sure that in the variable member definition it always starts with the prefix "#".
- Dimension Name is mandatory and must be an existing dimension in the current data action model. The version dimension is not supported. Measures are supported, for example: VARIABLEMEMBER #Total_Revenue OF [d/Measures]
- A virtual variable member can only be used in DATA and RESULTLOOKUP functions. When inputting "#" in DATA() or RESULTLOOKUP(), a list of all available virtual members will be shown.
In the following example of advanced logic virtual variables, you can see that:
- SumOfProducts is the temporary account for total sales revenue.
- Since the total sales are over 1000 (1500), the system calculates other income of 1500 x -.01 for each product.
