IRubricatorFactorExecutor.SetAttrCombination

Syntax

SetAttrCombination(Attributes: String; Value: Array);

Parameters

Attributes. Attributes identifiers are separated with semicolon (;).

Value. Array of attribute values specified in the Attributes parameter.

Description

The SetAttrCombination method sets a combination of attributes, by which time series data is extracted.

Comments

The SetAttrCombination method extracts only series with the specified combination of attributes. If time series are extracted by means of attribute selection constraint, the series are selected, which contain all available attribute combinations.

For example, there are the Country and Indicator attributes. If the selection Country = Afghanistan, Albania; Indicator = BCA, BEA selection is set, four series are extracted that contain all available combinations of these attributes. If the SetAttrCombination method is used, and the combination of attributes Afghanistan|BCA and Albania|BEA is set, only two series are extracted that contain only these attributes.

Example

Executing the example requires that the repository contains a time series database with the TSDB_MLNG identifier containing time series attributes with the COUNTRY and INDICATOR identifiers. These attributes must be links to the dictionary.

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

Sub uProc;
Var
    MB: IMetabase;
    RubDesc, DictDescr: IMetabaseObjectDescriptor;
    RubrIn: IRubricatorInstance;
    Cub: ICubeInstance;
    Dest: ICubeInstanceDestination;
    FactorExec: IRubricatorFactorExecutor;
    Exec: ICubeInstanceDestinationExecutor;
    Mat: IMatrix;
    Ite: IMatrixIterator;
    FactAttr: IMetaAttributes;
    
    CountryElements, IndicatorElements: IDimElements;
    SelArr: Array[2Of Variant;
    TmpArr: Array[2Of Integer;
Begin
    // Get repository
    MB := MetabaseClass.Active;
    // Get time series database
    RubDesc := MB.ItemById("TSDB_MLNG");
    RubrIn := RubDesc.Open(NullAs IRubricatorInstance;
    // Get time series attributes
    FactAttr := RubrIn.Facts.Dictionary.Attributes;
    // Get values of the COUNTRY attribute
    DictDescr := FactAttr.FindById("COUNTRY").ValuesObject;
    CountryElements := (DictDescr.Open(NullAs IDimInstance).Elements;
    // Get values of the INDICATOR attribute
    DictDescr := FactAttr.FindById("INDICATOR").ValuesObject;
    IndicatorElements := (DictDescr.Open(NullAs IDimInstance).Elements;
    // Create an array with combination of attributes for sampling
    TmpArr[0] := CountryElements.AttributeValue(10As Integer;
    TmpArr[1] := IndicatorElements.AttributeValue(10As Integer;
    SelArr[0] := TmpArr;
    TmpArr[0] := CountryElements.AttributeValue(20As Integer;
    TmpArr[1] := IndicatorElements.AttributeValue(20As Integer;
    SelArr[1] := TmpArr;
    // Create an object for extracting data from time series database 
    Cub := RubrIn As ICubeInstance;
    Dest := Cub.Destinations.DefaultDestination;
    Exec := Dest.CreateExecutor;
    FactorExec := Exec As IRubricatorFactorExecutor;
    // Specify that do not extract data of empty and deleted series
    FactorExec.WhereIsDeleted := False;
    FactorExec.WhereIsEmpty := False;
    // Set combination of attributes for sampling
    FactorExec.SetAttrCombination("COUNTRY;INDICATOR", SelArr);
    FactorExec.FactDataId := "FACTOR;INDICATOR;COUNTRY";
    // Extract data and output it to the console window
    Exec := FactorExec.AsCubeExecutor;
    Exec.PrepareExecute(Null);
    Exec.PerformExecute;
    Mat := Exec.Matrix;
    Ite := Mat.CreateIterator;
    Ite.Move(IteratorDirection.First);
    While Ite.Valid Do
        Debug.WriteLine(Ite.Value);
        Ite.Move(IteratorDirection.Next);
    End While;
End Sub uProc;

After executing the example the console window displays values of the time series formed by combination of the first two elements from dictionaries, to which the COUNTRY and INDICATOR attributes refer. Empty and deleted attributes are excluded from the sample.

See also:

IRubricatorFactorExecutor