![]() Previous |
![]() Next |
The MAINTAIN command with the ADD SESSION keywords adds a temporary calculated member to a dimension and applies it to the specified objects; or applies a previously-defined calculated member to the specified objects. The calculated member and its definition do not persist from session to session; both are deleted after the session in which they are created.
Syntax
MAINTAIN dimension ADD SESSION member_name [= calculation] -
[STEP DIMENSION (stepdim...)][apply-to]
where:
calculation is one of the following:
apply-to specifies the basis on which the custom aggregation is added using one of the following phrases:
Parameters
A dimension that is already defined in an attached analytic workspace. You can specify any type of dimension for dimension except a non-unique concat dimension or a base dimension of either a unique or non-unique concat dimension.
ADD SESSION indicates maintenance of a temporary calculated member.
Specifies the name of the temporary calculated member.
Indicates that you are defining a new calculated member.
A text expression that specifies the calculation used as a dynamic model to calculate custom member values. (See the SET command for more information about model equations.)
Indicates that the temporary calculated member is added as a custom aggregation using the specified dimension members. This clause effectively modifies the RELATION statement of aggmap objects that are the aggregation specification for variables dimensioned by dimension. Consequently, a MAINTAIN ADD SESSION statement that contains an AGGREGATION clause must also contain an APPLY WITH RELATION clause.
A text expression that specifies one or more dimension values to be used by the custom aggregation. When using a literal to specify multiple dimension members, separate the values with commas
Indicates that the calculation is a time-series function.
A text expression that specifies the dimension along which the time-series function is calculated. When using a literal to specify multiple dimension names, separate the names with commas.
Indicates that the calculated temporary member is added only to dimensions used by the specified aggmap objects.
A text expression that specifies the name of one or more aggmap objects to which the temporary calculated member is added. When using a literal to specify multiple aggmap objects, separate the names with commas. The temporary calculated member is added to each of the specified aggmap objects.
Indicates that the temporary calculated member is added only to dimensions used by the default aggmap objects for the specified variables.
A text expression that specifies the one or more variable names for which the temporary calculated member is added to. When using a literal to specify multiple variable names, separate the names with commas. The temporary calculated member is added to the default aggmap object of each specified variable.
Important: When a specified variable does not have a default aggmap, using this clause generates an error. Use AGGMAP SET or $AGGMAP to specify a default aggmap for the variable. |
Indicates that the temporary calculated member is added dimensions used by the aggregation specifications that contain a RELATION statement for the specified relation.
A text expression that specifies the name of the relation for which there must be a RELATION statement in the AGGMAP statement.
Usage Notes
Finding Out Information About Temporary Calculated Members
Once you have added a temporary calculated member using a MAINTAIN statement, you can use AGGMAPINFO to discover the temporary calculated members you have added, the equations used to calculate members, and the dimension members used in the right-hand side of equations used to calculate custom members.
Examples
Creating Calculated Dimension Members with Aggregated Values
Assume that an analytic workspace has a dimension named letter
and a variable named my_quantity
with the following definitions and permanent values.
DEFINE letter DIMENSION TEXT DEFINE my_quantity VARIABLE DECIMAL <letter> LETTER MY_QUANTITY -------------- ------------------------------ A 10.00 B 100.00
You can define temporary dimension members for the letter
dimension and aggregate data in my_quantity
for those members following these steps:
Determine the aggregation that you want to perform and define and populate the necessary supporting objects.
Create an empty child-parent relation for the letter
dimension
DEFINE letter.parentrel RELATION letter <letter> LETTER LETTER.PARENTREL -------------- ------------------------------ A NA B NA
Define a simple model to be used to calculate values associated with the letter
dimension
DEFINE my_model MODEL MODEL DIMENSION letter END
Define and compile a simple aggmap to be used to calculate my_quantity
values associated with the letter
dimension
DEFINE my_aggmap AGGMAP AGGMAP RELATION letter.parentrel PRECOMPUTE(NA) MODEL my_model PRECOMPUTE(NA) END COMPILE my_aggmap
Define a variable to contain the definition for the custom aggregation, This new variable is the same as my_quantity
except that has my_aggmap
as its default aggmap.
DEFINE my_quantity_definition VARIABLE DECIMAL <letter> CONSIDER my_quantity_definition PROPERTY '$AGGMAP' 'my_aggmap' REPORT my_quantity_definition LETTER MY_QUANTITY_DEFINITION -------------- ------------------------------ A NA B NA
Add temporary members to the letter
dimension and specify how variable values for those members are to be calculated.
MAINTAIN letter ADD SESSION 'C' = 'A' * 'B' MAINTAIN letter ADD SESSION 'D' = AGGREGATION('A', 'B') - APPLY TO AGGMAP my_aggmap MAINTAIN letter ADD SESSION 'E' = 'C' + 'D' - APPLY WITH RELATION letter.parentrel MAINTAIN letter ADD SESSION 'F' = 10 * 'E' - APPLY FOR VARIABLE my_quantity_definition
A report of the letter
dimension shows the new dimension members.
LETTER -------------- A B C D E F
Aggregate my_quantity
using the aggmap object named my_aggmap
.
REPORT AGGREGATE(my_quantity USING my_aggmap) AGGREGATE(MY_QUANTITY USING LETTER MY_AGGMAP) -------------- ------------------------------ A 10.00 B 100.00 C 1,000.00 D 110.00 E 1,110.00 F 11,100.00
Assume now that you issue the UPDATE and COMMIT statements to update and commit your analytic workspace. Then you detach the analytic workspace and end your session.
Later you start a new session and attach the same analytic workspace. When you ask for a description of the analytic workspace you can see that all of the objects that were in the analytic workspace when the UPDATE was issued still exist.
DEFINE LETTER DIMENSION TEXT DEFINE LETTER.PARENTREL RELATION LETTER <LETTER> DEFINE MY_QUANTITY VARIABLE DECIMAL <LETTER> DEFINE MY_MODEL MODEL MODEL DIMENSION letter END DEFINE MY_AGGMAP AGGMAP AGGMAP RELATION letter.parentrel PRECOMPUTE(NA) MODEL my_model PRECOMPUTE(NA) END DEFINE MY_QUANTITY_DEFINITION VARIABLE DECIMAL <LETTER>
However, when you report on the letter
dimension and the my_quantity
variable, the temporary dimension members that you added in the previous session and their related values in the my_quantity
variable do not exist.
LETTER -------------- A B REPORT letter.parentrel LETTER LETTER.PARENTREL -------------- ------------------------------ A NA B NA REPORT my_quantity LETTER MY_QUANTITY -------------- ------------------------------ A 10.00 B 100.00 LETTER MY_QUANTITY_DEFINITION -------------- ------------------------------ A NA B NA REPORT AGGREGATE(my_quantity USING my_aggmap) AGGREGATE(MY_QUANTITY USING LETTER MY_AGGMAP) -------------- ------------------------------ A 10.00 B 100.00