Basic Modeling Commands
OLAP DML commands for defining and running models
The following table lists the most common OLAP DML commands that you will use when you define and run models.
Writing equations in a model
When you write the equations in a model, you should keep these points in mind:
- Within a single dimension-based equation, all the dimension values must belong to the same dimension.
- If a model equation is based on a time dimension (with a data type of DAY, WEEK, MONTH, QUARTER, or YEAR), then you must use the dimension's VNF (value name format), rather than a date format, to specify the dimension's values.
- You cannot use ampersand substitution in model equations.
Writing DIMENSION and INCLUDE commands
When you write DIMENSION and INCLUDE commands, you should keep these points in mind:
- Any DIMENSION commands or INCLUDE command must come before the first equation in a model.
- In the DIMENSION commands, you must list the names of all the dimensions on which model equations are based. In the following example, GROSS.MARGIN, REVENUE, and COGS are values of the LINE dimension, so LINE is specified in a DIMENSION command.
dimension line
gross.margin = revenue - cogs
- DIMENSION commands must also list any dimension that is an argument to a function that refers to a dimension value. In the following example, MONTH must be specified in a DIMENSION command.
dimension line, month
revenue = lag(revenue, 1, month) * 1.05
- If a model contains an INCLUDE command, then it cannot contain any DIMENSION commands. The included model (or the root model in a hierarchy) must contain the DIMENSION commands needed by the parent model(s).
- If a model equation assigns results to a dimension value, then code is constructed that loops over the values of any of the other nontarget dimensions listed in the DIMENSION commands. The nontarget dimension listed first in the DIMENSION commands is treated as the slowest-varying dimension.
- A model will execute most efficiently when you observe the following guidelines for coordinating the dimensions in DIMENSION commands and the dimensions of the solution variable:
- List the model's target dimension as the first dimension in the DIMENSION commands and as the last dimension in the definition of the solution variable.
- In DIMENSION commands, list the nontarget dimensions in the reverse order of their appearance in the definition of the solution variable. This means that the nontarget dimensions will have the same order in the model and in the solution variable in terms of fastest-varying and slowest-varying dimension.
- If the solution variable has dimensions that are not used or referred to in model equations, then do not include them in DIMENSION commands.
- If your analytic workspace contains a variable whose name is the same as a dimension value, or if the same dimension value exists in two different dimensions, then there could be ambiguities in your model equations. Since you can use a variable and a dimension value in exactly the same way in a model equation, a name might be the name of a variable, or it might be a value of any dimension in your analytic workspace.
- Your DIMENSION commands are used to determine whether each name reference in an assignment statement (that is, the = command) is a variable or a dimension value. "Compiling a Model" explains how the name references are resolved.
Related information
For more information, see the following table.