Using Related Dimensions in Expressions


The syntax of some OLAP DML statements (for example, some variations of the LIMIT command) include two arguments: a "dimension", and a "related dimension". Other OLAP DML statements (for example, AVERAGE, ANY, COUNT, CUMSUM, NONE, LARGEST, SMALLEST, and TOTAL) allow you to specify the dimensionality of the result in terms of a "related dimension". In these contexts, the "related dimension" is any dimension that shares a relation with another dimension.

Even though the value that you specify for the arguments in these statements is the name of a dimension, in actuality Oracle OLAP uses a relation between the dimensions to perform its calculations. When the two dimensions share only one relation, the behavior is clear. Oracle OLAP performs the calculation based on the values in that relation.

However, when two dimensions share more than one relation, then the behavior is less clear. In some cases, as with the LIMIT command (using LEVELREL) command, you can specify the shared relation you want Oracle OLAP to use. In other cases, the statement syntax does not allow you to specify the name of a relation. In this case, Oracle OLAP uses the "default relation" between the dimensions when performing the calculations. The "default relation" is either the first relation that Oracle OLAP encounters that meets the need of the statement; or the relation defined as the "default relation" using the RELATION command.

Consequently, to ensure predictable results, it is recommended that when you define two or more relations between dimensions that you also use the RELATION command to define, for every object dimensioned by one of these dimensions, the default relation between the two dimensions.