SUBSTITUTION VARIABLES / VARIABLES DE SUSTITUCIÓN

English (Español a continuación)

I.-Introduction

The substitution variable is used in the various artifacts in the cube to collect values ​​that need to be changed periodically with a certain frequency.

  • It is especially interesting when a reference must be periodically updated in numerous artifacts: for example, «Current Month», «Previous Month», «Current Year», «Previous Year» …

Let us suppose that the “Current Month” is used in the calculation script and it appears in numerous sections of the script. Every month you have to update the current month: there are two options:

  • Each month, replace the previous month with the new month in each of the appearances: if it appears 20 times, 20 substitutions will have to be made.
  • Use a substitution variable (for example, “CurrentMonth”): instead of the current month, the substitution variable “&CurrentMonth” will appear in the script (preceded by the symbol “&”); each month the value of this variable will simply have to be updated (a single substitution).

The substitution variable can be used throughout the cube’s artifact library:

  • Calculation script
  • Member formulas
  • Filters
  • Report scripts
  • MDX scripts
  • Loading rules
  • Partitions

Substitution variables can take:

  • Numerical values ​​(for example: Increment = 50).
  • Name of a member of the outline (for example: CurrentMonth = January).
  • Ranks (for example: 3LastMonths = February: April).

The scope of the substitution variable can be:

  • Global: applicable to all applications / cubes on the server.
  • Application: applicable to all the bases of an application.
  • Database: applicable to a specific database.

As far as possible, it is advisable to define the substitution variables in the widest possible scope.

  • For example: if the variable ActYear (Current Year) is used in most applications / databases, it is convenient to define a single variable at the server level.

If the same substitution variable exists in different settings, its order of prevalence is:

  • Database settings.
  • Application settings.
  • Server settings.

When the substitution variable is used in an artifact (for example, in a calculation script) it is preceded by the symbol «&».

For example: we have defined the variable «ActYear» (current year):

  • FIX (&ActYear, Germany, Sales)
  • ENDFIX

For example, in the following function:

  • @RELATIVE (&Market, 0);

II.- Creation / Modification / Deletion of a substitution variable

a) Creation: Right-click on the server; then select «Create» / «Variable».

  • In the window opened, you must specify whether it applies to all applications or to a specific one.
  • If a specific application has been specified, it can be determined whether it applies to all the databases of that application or to a specific one.
  • Next, you must indicate the name of the variable and its value.

It can also be created through a Maxl with the following statement:

  • alter database ‘Application’. ’Database’ add variable ‘Variable name’ ‘Value’;

Attention: the name of the application, the name of the database, the name of the variable and the value we assign to it always go between ‘ ‘.

b) Modification: Right-click on the server; then select «Edit» / «Variable».

  • A window opens showing all the variables registered on the server (application to which it is applied / database to which it is applied / variable name / value).

To modify them, double click on any of these 4 fields that you want to modify:

  • In the case of «Application» / «Database» a list is displayed in which the scope of application can be modified.
  • In the case of «Name» / «Value» it is modified directly in that box.

After making a change, click on the «Set» button.

  • Variables must be modified one by one; every time you modify one you have to click on «Set».

Its value can also be modified through a Maxl with the following instruction:

  • alter database ‘Application’. ’Database’ set variable ‘Variable name’ ‘Value’;

c) Deletion: Right click on the server; then select «Edit» / «Variable».

  • In the window opened, click on the variable that you want to delete and then click on the lower button «Delete».

III.- Copying a substitution variable

If you want to copy a substitution variable in another «Application» / «Database»:

  • Right-click on the server; then select «Edit» / «Variable». A window opens showing all the variables on the server.
  • Then select the variable to be copied (by clicking on it).
  • At the bottom, click on the «Copy» button and a window opens in which you can select the area where you want to copy (all applications or a specific one / all the databases of that application or a specific one).
  • Next, select the variable (s) of that database that you want to copy.

Español

I.- Introducción

La variable de sustitución se utiliza en los distintos artefactos del cubo para recoger valores que hay que modificar periódicamente con cierta frecuencia.

  • Es especialmente interesante cuando una referencia hay que actualizarla periódicamente en numerosos artefactos: por ejemplo, “Mes Actual”, “Mes Anterior”, “Año Actual”, “Año Anterior”…

Supongamos que en el script de cálculo se utiliza el “mes actual” y figura en numerosos apartados del script. Cada mes hay que actualizar el mes actual: hay dos opciones:

  • Cada mes ir sustituyendo el mes anterior por el nuevo mes en cada una de las apariciones: si figura 20 veces habrá que hacer 20 sustituciones.
  • Utilizar una variable de sustitución (por ejemplo, “MesActual”): en el script en lugar del mes actual figurará la variable de sustitución “&MesActual” (va precedida del símbolo “&”); cada mes simplemente habrá que actualizar el valor de esta variable (una sola sustitución).

La variable de sustitución se puede utilizar en toda la biblioteca de artefactos del cubo:

  • Script de cálculo
  • Fórmulas de un miembro
  • Filtros
  • Scripts de informes
  • Scripts MDX
  • Reglas de carga
  • Particiones

Las variables de sustitución pueden tomar:

  • Valores numéricos (por ejemplo: Incremento = 50).
  • Nombre de un miembro del outline (por ejemplo: MesActual = Enero).
  • Rangos (por ejemplo: 3UltMeses = Febrero:Abril).

El ámbito de la variable de sustitución puede ser:

  • Global: aplicable a todas las aplicaciones / cubos del servidor.
  • Aplicación: aplicable a todas las bases de una aplicación.
  • Base de datos: aplicable a una base específica.

En la medida de lo posible es recomendable definir las variables de sustitución en el mayor ámbito de aplicación posible.

  • Por ejemplo: si la variable ActYear (Año actual) se utiliza en la mayoría de las aplicaciones / bases de datos, es conveniente definir una única variable a nivel de servidor.

Si existe la misma variable de sustitución en distintos ámbitos su orden de prevalencia es:

  • Ámbito base de datos.
  • Ámbito aplicación.
  • Ámbito servidor.

Cuando la variable de sustitución se utiliza en un artefacto (por ejemplo, en un script de cálculo) va precedida del símbolo “&”.

Por ejemplo: suponemos que hemos definido la variable “ActYear” (año actual):

  • FIX(&ActYear,Alemania,Ventas)
  • ENDFIX

Por ejemplo, en la siguiente función:

  • @RELATIVE(&Market,0);

II.- Creación / Modificación / Borrado de una variable de sustitución

a) Creación: Se hace click con el botón derecho sobre el servidor; se selecciona “Crear” / “Variable”.

  • En la ventana que se abre hay que especificar si se aplica a todas las aplicaciones o a alguna en concreto.
  • Si se ha especificado una aplicación concreta se puede determinar si se aplica a todas las bases de esa aplicación o a alguna en concreto.
  • A continuación hay que indicar el nombre de la variable y su valor.

También se puede crear a través de un Maxl con la siguiente instrucción:

  • alter database ‘Aplicación’.’Base de datos’ add variable ‘Nombre variable’ ‘Valor’;

Atención: el nombre de la aplicación, el de la base de datos, el de la variable y el valor que le asignamos van siempre entre ‘ ‘.

b) Modificación: Se hace click con el botón derecho sobre el servidor; se selecciona “Editar” / “Variable”.

  • Se abre una ventana en la que figuran todas las variables dadas de alta en el servidor (aplicación a la que se aplica / base a la que se aplica / nombre de la variable / valor).

Para modificarlas se hace doble click en cualquiera de estos 4 campos que se quiera modificar:

  • En el caso de “Aplicación” / “Base de datos” se despliega una lista en la que se puede modificar el ámbito de aplicación.
  • En el caso de “Nombre” / “Valor” se modifica directamente en esa casilla.

Después de realizar un cambio hay que hacer click en el botón “Establecer”.

  • Las variables hay que modificarlas de una en una; cada vez que se modifica una hay que hacer click en “Establecer”.

También se puede modificar su valor a través de un Maxl con la siguiente instrucción:

  • alter database ‘Aplicación’.’Base de datos’ set variable ‘Nombre variable’ ‘Valor’;

c) Borrado: Se hace click con el botón derecho sobre el servidor; se selecciona “Editar” / “Variable”.

  • En la ventana que se abre se hace click sobre la variable que se quiere borrar y a continuación se hace click en el botón inferior “Suprimir”.

III.- Copiado de una variable de sustitución

Si se quiere copiar una variable de sustitución en otra “Aplicación“ / “Base de datos”:

  • Se hace click con el botón derecho sobre el servidor; se selecciona “Editar” / “Variable”. Se abre una ventana en la que figuran todas las variables del servidor.
  • Se selecciona la variable a copiar (haciendo click sobre ella).
  • Abajo se hace click en el botón “Copiar” y se abre una ventana en la que se puede seleccionar el ámbito donde se quiere copiar (todas las aplicaciones o una en concreto / todas las bases de esa aplicación o una en concreto).
  • A continuación se selecciona la(s) variable(s) de esa base que se quiere copiar.
Anuncio publicitario