ICustomDimAttribute.Expression

Syntax

Expression: IExpression;

Description

The Expression property returns the expression, based on which attribute values are formed.

Comments

An expression may use parameters of designed dictionary, other attributes, various mathematical operations and functions.

Example

Executing the example requires that the repository contains a calculated cube with the CALC_CUBE identifier.

Add links to the Cubes, Dal, Dimensions, Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MObj: IMetabaseObject;
    Cube: ICalculatedCube;
    CustDim: ICustomDimension;
    CustAttrs: ICustomDimAttributes;
    Attr: ICustomDimAttribute;
    CustDimParam: IMetabaseObjectParam;
Begin
    // Get cube
    MB := MetabaseClass.Active;
    MObj := MB.ItemById("CALC_CUBE").Edit;
    Cube := MObj As ICalculatedCube;
    // Get cube facts dimension
    CustDim := Cube.InternalFactDimension;
    //Create the у  parameter of custom dictionary
    MObj := CustDim As IMetabaseObject;
    CustDimParam := MObj.Params.Add;
    CustDimParam.Id := "PARAM1";
    CustDimParam.Name := "PARAM1";
    CustDimParam.DataType := DbDataType.Integer;
    CustDimParam.DefaultValue := 100;
    // Get collection of facts dimension attributes
    CustAttrs := CustDim.Attributes;
    // Create a new attribute with parameter in expression
    Attr := CustAttrs.Add;
    Attr.Id := "EXPR1";
    Attr.Name := "Expression1";
    Attr.DataType := DbDataType.Integer;
    Attr.Visible := True;
    Attr.Expression.AsString := "PARAM1 + Round(RandBetween(0,100))";
    //Save
    (CustDim As IMetabaseObject).Save;
End Sub UserProc;

After executing the example, the structure of the designed dictionary used as a fact dimension of calculated cube is edited. A parameter is added to the dictionary structure, an attribute is added to the collection of dictionary attributes, which values will be calculated by the expression that uses the created parameter.

See also:

ICustomDimAttribute