English (Español a continuación)
Temporary variables are defined within the calculation script and take values exclusively for that calculation script.
We distinguish two types of temporary variables:
- VAR: contains a single value.
- ARRAY: the variable takes a specific value for each member of the specified dimension.
In both cases it can only be assigned numerical values; they cannot be matched to text strings.
It is recommended to declare at the beginning of the calculation script all the temporary variables (VAR or ARRAY) that are used in that script.
a) VAR
The command VAR allows to define a variable:
- VAR Target = 500;
The syntax of this command is: VAR Name [= value];
- Name: it is the name that we give to the variable and it cannot coincide with the name of a member of the outline.
- [= value]: is optional; if no value is assigned at the time of declaration, it takes the value #missing. Then it can be given value in the calculation script.
For example:
- VAR Target = 500;
- VAR Target;
In this second case then in the calculation script it can be assigned a value but it has to be defined within a block opening, if not it gives an error:
For example:
- FIX ()
- Sales (
- Target = 200;
- )
- ……
- Sales (
- ENDFIX
You can also use a conditional structure to give it different values based on certain conditions being met.
For example:
- FIX ()
- Sales (
- IF (@ISMBR (January))
- Target = 200;
- ELSEIF (@ISMBR (February))
- Target = 250;
- …
- ENDIF
- )
- ……
- Sales (
- ENDFIX
When defining a variable and a value is assigned, it cannot include a mathematical formula:
- VAR Increment = 10; (correct)
- VAR Increment = 10 + 2; (incorrect)
However you can include formulas when the variable is assigned a value within a calculation script.
- FIX ()
- Sales (
- Target = 200 + 50;
- )
- ……
- ENDFIX
You can also use the command VAR to declare multiple variables, separated by commas:
- VAR Target, Growth, Margin;
In this case the variables are given a value in the calculation script:
Example:
- FIX ()
- Sales (
- Target = 150;
- Growth = 0.15;
- Margin = 0.03;
- )
- ……
- Sales (
- ENDFIX
These variables can be used to store intermediate calculations.
- For example, with the LOOP … ENDLOOP structure
b) ARRAY
This command allows to define a variable that will take different values for each member of the same dimension.
Its syntax is: ARRAY Name [Dimension] = {list of values};
Name: name of the variable. Quotes cannot be used with the variable name.
[Dimension]: Indicates the dimension to which this variable is associated. The number of members of this dimension determines the number of different values that this variable takes (one for each member of the dimension).
- For example: if the dimension included in the ARRAY is “Markets” and it has 8 members, the variable defined in this ARRAY will take 8 different values.
List of values: it is optional, it indicates the value that this variable will take for each member of the specified dimension. The values are separated by commas and are assigned to the members of the specified dimension according to their order in the outline.
For example, suppose the dimension “Months” made up of 12 members: January… December. We create the following ARRAY in which we define the variable «Increments»:
- ARRAY Increments [Months] = {8,5,6,7,8,9,10,10,11,11,12,12};
The variable «Increments» will take:
- The value 8 for January.
- The value 5 for February.
- The value 6 for March.
- …
If the value is not determined when the ARRAY is defined, the variable will take the value #missing for each member of the indicated dimension and then a value will be assigned to it in the calculation.
Let’s see an example:
- ARRAY Initial_Target [Years];
We create an array with the variable «Initial_Target». In the calculation script we are going to equal this variable to the projected sales of each year. Later we are going to equal the «Target» of each year to the value of this variable multiplied by 1.1;
- ARRAY Initial_Target [Years];
- FIX (@IDESCENDANTS (”Europe”))
- Target(
- Initial_Target = «Projected sales»;
- Initial_Target * 1.1;
- )
- Target(
- ENDFIX
ATTENTION: to give value to the variable defined in the ARRAY, it must be included within a block opening:
- Target(
- Initial_Target = «Projected sales»;
- …
- )
Otherwise it gives an error. For example, it would not be valid:
- ARRAY Initial_Target [Years];
- FIX (@IDESCENDANTS (”Europe”))
- Initial_Target = «Projected sales»;
- Target = Initial_Target * 1.1;
- ENDFIX
Several ARRAYS can be created simultaneously (separated by commas):
- ARRAY Increments [Markets], Bonus [Sellers], Margin [Products];
In the example above:
- The variable «Increments» will take values for the members of the dimension «Markets».
- The variable «Bonus» will take values for the members of the dimension «Sellers».
- The variable «Margin» will take values for the members of the dimension «Products».
Let’s see an example of using the command ARRAY: suppose we have the dimension «Year» that includes 6 members ranging from 2020 to 2025. We are going to create an ARRAY with a variable called «Variation»:
- ARRAY Variation [Years] = {10,12,15,15,16,16};
Let us suppose the data for the German market are:

We are going to use this variable to set the «Target» for sales for these years by applying the following formula:
- «Target» = «Projected sales» * Variation
We will use the following calculation script:
- ARRAY Variation [Years] = {10,12,15,15,16,16};
- FIX (Germany)
- Target = «Projected sales» * Variation;
- ENDFIX
After applying this calculation we obtain the following result:

When you have to use different variables for each member of a dimension, it is much more efficient to use the command ARRAY than to use the command VAR and define different variables for each member.
Let’s see an example: suppose we have the dimension «Currency», with the following members:

And we use the exchange rate to calculate the accounts in the different currencies.
It is more efficient to define an ARRAY with exchange rates:
- ARRAY Exchange_type [Currency] = {1,1,211,0,860,7,804,132.58,89,629,24,080.88,799};
Than define a VAR variable for each currency.
Español
Las variables temporales se definen dentro del script de cálculo y toman valores exclusivamente para ese script de cálculo.
Distinguimos dos tipos de variables temporales:
- VAR: contiene un único valor.
- ARRAY: la variable toma un valor específico para cada miembro de la dimensión especificada.
En ambos casos tan sólo se le pueden asignar valores numéricos; no se pueden igualar a cadenas de texto.
Es recomendable declarar al comienzo de un script de cálculo todas las variables temporales (VAR o ARRAY) que se utilizan en dicho script.
a) VAR
El comando VAR permite definir una variable:
- VAR Objetivo = 500;
La sintaxis de este comando es: VAR Nombre [= valor];
- Nombre: es el nombre que le damos a la variable y no puede coincidir con el nombre de un miembro del outline.
- [= valor]: es opcional; si no se le asigna valor en el momento de la declaración toma el valor #missing. Luego se le puede dar valor en el script de cálculo.
Por ejemplo:
- VAR Objetivo = 500;
- VAR Objetivo;
En este segundo caso, luego en el script de cálculo se le puede asignar un valor pero se tiene que definir dentro de una apertura de bloques, si no da error:
Por ejemplo:
- FIX()
- Ventas(
- Objetivo = 200;
- )
- ……
- Ventas(
- ENDFIX
También se puede utilizar una estructura condicional para darle distintos valores en función de que se cumplan determinadas condiciones.
Por ejemplo:
- FIX()
- Ventas(
- IF(@ISMBR(Enero))
- Objetivo = 200;
- ELSEIF(@ISMBR(Febrero))
- Objetivo = 250;
- …
- ENDIF
- )
- ……
- Ventas(
- ENDFIX
Cuando al definir una variable se le asigna un valor, este no puede incluir una fórmula matemática:
- VAR Incremento = 10; (correcto)
- VAR Incremento = 10 + 2; (incorrecto)
Si puede incluir fórmulas cuando a la variable se le asigna un valor dentro de un script de cálculo.
- FIX()
- Ventas(
- Objetivo = 200 + 50;
- )
- ……
- Ventas(
- ENDFIX
También se puede utilizar el comando VAR para declarar varias variables, separadas por coma:
- Var Objetivo, Crecimiento, Margen;
En este caso se les da valor a las variables en el script de cálculo:
Ejemplo:
- FIX()
- Ventas(
- Objetivo = 150;
- Crecimiento = 0.15;
- Margen = 0.03;
- )
- ……
- Ventas(
- ENDFIX
Estas variables se pueden utilizar para almacenar cálculos intermedios.
- Por ejemplo, con la estructura LOOP… ENDLOOP
b) ARRAY
Este comando permite definir una variable que va a tomar valores diferentes para cada miembro de una misma dimensión.
Su sintaxis es: ARRAY Nombre [Dimensión] = {lista de valores};
Nombre: nombre de la variable. No se pueden utilizar comillas con el nombre de la variable.
[Dimensión]: Indica la dimensión a la cual va asociada esta variable. El número de miembros de esta dimensión determina el número de valores diferentes que toma esta variable (uno por cada miembro de la dimensión).
- Por ejemplo: si la dimensión incluida en el ARRAY es “Mercados” y tiene 8 miembros, la variable definida en este ARRAY va a tomar 8 valores diferentes.
Lista de valores: es opcional, indica el valor que va a tomar esta variable para cada miembro de la dimensión especificada. Los valores van separados por comas y se asignan a los miembros de la dimensión especificada según su orden en el outline.
Por ejemplo, supongamos la dimensión “Meses” integradas por 12 miembros: Enero … Diciembre. Creamos el siguiente ARRAY en el que definimos la variable “Incrementos”:
- ARRAY Incrementos [Meses] = {8,5,6,7,8,9,10,10,11,11,12,12};
La variable “Incrementos” tomará:
- El valor 8 para enero.
- El valor 5 para febrero.
- El valor 6 para marzo.
- …
Si cuando se define el ARRAY no se determina el valor la variable esta tomará el valor #missing para cada miembro de la dimensión indicada y luego en el cálculo se le asignará un valor.
Veamos un ejemplo:
- ARRAY Obj_Inicial [Años];
Creamos un array con la variable “Obj_Inicial”. En el script de cálculo vamos a igualar esta variable a las ventas proyectadas de cada año. Posteriormente vamos a igualar el “Objetivo” de cada año al valor de esta variable multiplicado por 1,1;
- ARRAY Obj_Inicial [Años];
- FIX(@IDESCENDANTS(”Europa”))
- Objetivo(
- Obj_Inicial = “Ventas proyectadas”;
- Obj_Inicial * 1.1;
- )
- Objetivo(
- ENDFIX
ATENCIÓN: para darle valor a la variable definida en el ARRAY hay que incluirla dentro de una apertura de bloque:
- Objetivo(
- Obj_Inicial = “Ventas proyectadas”;
- …
- )
En caso contrario da error. Por ejemplo, no sería válido:
- ARRAY Obj_Inicial [Años];
- FIX(@IDESCENDANTS(”Europa”))
- Obj_Inicial = “Ventas proyectadas”;
- Objetivo = Obj_Inicial * 1.1;
- ENDFIX
Se pueden crear varios ARRAYS simultáneamente (van separadas por coma):
- ARRAY Incrementos [Mercados], Bono [Vendedores], Margen [Productos];
En el ejemplo anterior:
- La variable “Incrementos” tomará valores para los miembros de la dimensión “Mercados”.
- La variable “Bono” tomará valores para los miembros de la dimensión “Vendedores”.
- La variable “Margen” tomará valores para los miembros de la dimensión “Productos”.
Veamos un ejemplo de utilización del comando ARRAY: supongamos que tenemos la dimensión “Año” que incluye 6 miembros que van del 2020 al 2025. Vamos a crear un ARRAY en el que vamos a fijar una variable que vamos a denominar “Variación”:
- ARRAY Variación [Años] = {10,12,15,15,16,16};
Supongamos que los datos de partida del mercado alemán son:

Vamos a utilizar esta variable para fijar el “Objetivo” de ventas de estos años aplicando la siguiente fórmula:
- “Objetivo” = “Ventas proyectadas” * Variación
Usaremos el siguiente script de cálculo:
- ARRAY Variación [Años] = {10,12,15,15,16,16};
- FIX(Alemania)
- Objetivo = “Ventas proyectadas” * Variación;
- ENDFIX
Tras aplicar este cálculo obtenemos el siguiente resultado:

Cuando se tienen que utilizar diferentes variables para cada miembro de una dimensión, es mucho más eficiente utilizar el comando ARRAY que utilizar el comando VAR y definir variables diferentes para cada miembro.
Veamos un ejemplo: supongamos que tenemos la dimensión “Divisas”, con los siguientes miembros:

Y que tenemos que utilizar el tipo de cambio para calcular las cuentas en las diferentes monedas.
Resulta más eficiente definir un ARRAY con los tipos de cambio:
- ARRAY Tipo_cambio [Divisas] = {1,1.211,0.860,7.804,132.58,89.629,24.080,88.799};
Que definir una variable VAR para cada moneda.