IMsDimIteratorFilter.AdvancedFilter

Syntax

AdvancedFilter: IMsDimIteratorAdvancedFilter;

Description

The AdvancedFilter property returns advanced filter parameters

Comments

The advanced filter enables the user to select the elements corresponding to the specified condition.

If filter elements have been already set in one the properties IMsDimIteratorFilter.ElementGroup, IMsDimIteratorFilter.ParameterAsGroup, IMsDimIteratorFilter.ParameterAsSelection or IMsDimIteratorFilter.Selection, they are checked for correspondence to the set condition. If elements are not set, all dictionary elements are checked for correspondence to the condition.

Example

Executing the example requires that the repository contains a modeling container with the MS_STAT identifier containing a metamodel with the METAMODEL_MULTIDIMITERATOR identifier. A data source for the container is a time series database containing time series attributes with the CITY and INDICATOR identifiers. These attributes should be links to the dictionary. A dictionary, to which the CITY attribute refers, should contain a parameter with logical type with the ISCAPITAL identifier.

The container must also contain a modeling problem with the PROBLEM_MULTIDIMITERATOR identifier calculating the METAMODEL_MULTIDIMITERATOR metamodel and the model with the MODEL_MULTIDIMITERATOR identifier.

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

Sub UserProc;
Var
    mb: IMetabase;
    MsKey: Integer;
    pMetaModel: IMsMetaModel;
    Ms: IMsModelSpace;
    DS: IRubricator;
    Attributes: IMetaAttributes;
    CDict, IDict: IMetabaseObjectDescriptor;
    Chain: IMsCalculationChainEntries;
    mParams: IMsModelParams;
    CParam, IParam: IMsModelParam;
    iterator: IMsCalculationChainMultiDimIterator;
    dimInstC, dimInstI: IDimInstance;
    IterDims: IMsDimIteratorDimensions;
    CIterDim, IIterDim: IMsDimIteratorDimension;
    Filter: IMsDimIteratorFilter;
    dimSelC, dimSelI: IDimSelection;
    CAdvFilter: IMsDimIteratorAdvancedFilter;
    CAdvFilterCond: IMsDimIteratorAdvancedFilterCondition;
    model: IMsModel;
    Problem: IMsProblem;
    Calc: IMsProblemCalculation;
    i: Integer;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get modelling container key
    MsKey := mb.GetObjectKeyById("MS_STAT");
    // Get model
    pMetaModel := mb.ItemByIdNamespace("METAMODEL_MULTIDIMITERATOR", MsKey).Edit As IMsMetaModel;
    // Get modeling container
    Ms := mb.Item(MsKey).Bind As IMsModelSpace;
    // Get time series database
    // which is a data source for modeling container
    DS := Ms.DefaultObject.Bind As IRubricator;
    // Get factor attributes
    Attributes := DS.Facts.Attributes;
    // Get dictionaries used as a base for the CITY and INDICATOR attributes
    CDict := Attributes.FindById("CITY").ValuesObject;
    IDict := Attributes.FindById("INDICATOR").ValuesObject;
    // Get and clear metamodel parameters
    mParams := pMetaModel.Params;
    mParams.Clear;
    // Add a parameter based on dictionary of the CITY attribute
    CParam := mParams.Add;
    CParam.DataType := DbDataType.integer;
    CParam.Hidden := True;
    CParam.Id := "CITY";
    CParam.Name := "City";
    CParam.LinkedObject := CDict;
    CParam.ParamType := TsParamType.Selection;
    dimInstC := CDict.Open(NullAs IDimInstance;
    dimSelC := dimInstC.CreateSelection;
    dimSelC.SelectAll;
    CParam.DefaultValue := dimSelC;
    // Add a parameter based on dictionary of the INDICATOR attribute
    IParam := mParams.Add;
    IParam.DataType := DbDataType.Integer;
    IParam.Hidden := True;
    IParam.Id := "INDICATOR";
    IParam.Name := "Factor";
    IParam.LinkedObject := IDict;
    IParam.ParamType := TsParamType.Selection;
    dimInstI := IDict.Open(NullAs IDimInstance;
    dimSelI := dimInstI.CreateSelection;
    dimSelI.SelectAll;
    // Get and clear metamodel calculation chain
    Chain := pMetaModel.CalculationChain;
    Chain.Clear;
    // Add a multidimensional iterator to metamodel calculation chain      
    Iterator := Chain.AddMultiDimIterator("Multidimensional iterator");
    // Get iterated dimensions
    IterDims := Iterator.Dimensions;
    // Add a dimension based on dictionary of the CITY attribute
    CIterDim := IterDims.Add(dimInstC);
    // Set dimension parameter
    CIterDim.Parameter := CParam;
    // Set filter of elements
    Filter := CIterDim.Filter;
    Filter.Selection := dimSelC;
    // Get advanced filter
    CAdvFilter := Filter.AdvancedFilter;
    // Display name of filtered dimension
    Debug.WriteLine("Dimension containing advanced filter: " + (CAdvFilter.Owner As IMsDimIteratorFilter).Owner.Name);
    // Add an advanced filtering condition
    CAdvFilterCond := CAdvFilter.Add;
    // Set filtered attribute
    CAdvFilterCond.Attribute := dimInstC.Attributes.FindById("ISCAPITAL").Attribute;
    // Set comparison operator
    CAdvFilterCond.Operator_ := MsAdvancedFilterConditionOperator.Equal;
    // Set required attribute value
    CAdvFilterCond.Value := True;
    // Add a dimension based on dictionary of the INDICATOR attribute
    IIterDim := IterDims.Add(dimInstI);
    // Set dimension parameter
    IIterDim.Parameter := IParam;
    // Set filter of elements
    Filter := IIterDim.Filter;
    Filter.Selection := dimSelI;
    // Add model to multidimensional iterator
    model := mb.ItemByIdNamespace("MODEL_MULTIDIMITERATOR", MsKey).Bind As IMsModel;
    Iterator.Contents.AddModel(model);
    // Save changes in metamodel
    (pMetaModel As IMetabaseObject).Save;
    // Check advanced filter. Display dictionary elements in the console window,
    // that correspond to filter
    Problem := mb.ItemByIdNamespace("PROBLEM_MULTIDIMITERATOR", MsKey).Bind As IMsProblem;
    Calc := Problem.Calculate(Problem.CreateCalculationSettings);
    Debug.WriteLine("Dictionary elements corresponding to filter: ");
    Debug.Indent;
    For i := 0 To dimSelC.SelectedCount - 1 Do
        If CAdvFilter.Test(dimSelC.Element(i), Calc) Then
            Debug.WriteLine(dimSelC.Dimension.Elements.Name(dimSelC.Element(i)));
        End If;
    End For;
End Sub UserProc;

After executing the example a multidimensional iterator is created in the metamodel. A model is added to the iterator. An advanced filter is added for the dimension based on a dictionary of the CITY attribute: only the elements, which value of the ISCAPITAL attribute is set to True are added to the iterator. These elements are displayed in the console window.

See also:

IMsDimIteratorFilter