ICubeMetaLoaderBinding.Filter

Syntax

Filter: IDimensionModel;

Description

The Filter property returns selection of indicators, by which data is loaded.

Comments

A filter is not created by default. And loading is executed by all attribute indicators.

The indicators are selected on first addressing this property. All indicators are included into this selection. Selection can be changed if required.

NOTE. If it is not necessary to create a filter by attribute, avoid addressing the current property in the code. The HasFilter property can be used to check if the created filter is present.

Example

Executing the example requires a time series database with the OBJ_FC identifier and a time series export file C:\Fixed.xlsx. The repository must also contain an MDM repository with the RDS_REPO identifier. This repository should have dictionaries with the DICT_CTR, DICT_IND and UNITS identifiers. The COUNTRY attribute of the time series database refers to the DICT_CTR dictionary, the INDICATOR attribute is a link to the DICT_IND dictionary, and measurement units refer to the UNITS dictionary.

The C:\Fixed.xlsx file, for which the example is created

Sub UserProc;
Var
    Mb: IMetabase;
    NsiDescr: IMetabaseObjectDescriptor;
    CubeMetaLoader: ICubeMetaLoader;
    CrInfo: IMetabaseObjectCreateInfo;
    Obj: IMetabaseObject;
    ObjDesc: IMetabaseObjectDescriptor;
    CubeMetaLoaderBindings: ICubeMetaLoaderBindings;
    CalendarBinding: ICubeMetaLoaderBinding;
    Filter: IDimSelection;
    Indexes: IDimIndexesInstance;
    CountryBinding: ICubeMetaLoaderBinding;
    IndicatorBinding: ICubeMetaLoaderBinding;
    UnitBinding: ICubeMetaLoaderBinding;
    ScaleBinding: ICubeMetaLoaderBinding;
    LevelBinding: ICubeMetaLoaderBinding;
    Excel: IDtExcelProvider;
    Provider: IDatasetDataProvider;
    Log: ICubeMetaLoaderLog;
    Entry: ICubeMetaLoaderLogEntry;
    key, Count, i: Integer;
Begin
    Mb := MetabaseClass.Active;
    NsiDescr := Mb.ItemById("RDS_REPO");
    CrInfo := Mb.CreateCreateInfo;
    CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_CUBEMETALOADER;
    CrInfo.Id := "CUBEMETALOADER";
    CrInfo.Permanent := False;
    ObjDesc := Mb.CreateObject(CrInfo);
    Obj := ObjDesc.Edit;
    CubeMetaLoader := Obj As ICubeMetaLoader;
    CubeMetaLoader.LoadType := CubeMetaLoaderLoadType.CreateAndUpdate;
    CubeMetaLoader.Rubricator := Mb.ItemById("OBJ_FC").Bind As IRubricator;
    CubeMetaLoaderBindings := CubeMetaLoader.Bindings;
    CalendarBinding := CubeMetaLoaderBindings.Add;
    CalendarBinding.BindingType := CubeMetaLoaderBindingType.Calendar;
    CalendarBinding.CalendarOptions.Levels := DimCalendarLevelSet.Year;
    CalendarBinding.CalendarDateFormat := "$Year$";
    CalendarBinding.FieldType := CubeMetaLoaderFieldType.Index;
    CalendarBinding.Field := "5";
    CalendarBinding.EndField := "12";
    CalendarBinding.ByColumns := True;
    CalendarBinding.HeaderRow := 0;
    CalendarBinding.FillGaps := True;
    IndicatorBinding := CubeMetaLoaderBindings.Add;
    IndicatorBinding.BindingType := CubeMetaLoaderBindingType.Attribute;
    IndicatorBinding.Attribute := "INDICATOR";
    IndicatorBinding.Field := "0";
    IndicatorBinding.FieldType := CubeMetaLoaderFieldType.Index;
    IndicatorBinding.Dimension := Mb.ItemByIdNamespace("DICT_IND", NsiDescr.Key).Bind As IDimensionModel;

    // IX_CODE - unique key of the DICT_IND dictionary
    IndicatorBinding.Index := "IX_CODE";
    IndicatorBinding.KeyAttribute := "KEY";
    IndicatorBinding.FillGaps := True;
    CountryBinding := CubeMetaLoaderBindings.Add;
    CountryBinding.BindingType := CubeMetaLoaderBindingType.Attribute;
    CountryBinding.Attribute := "COUNTRY";
    CountryBinding.Field := "1";
    CountryBinding.FieldType := CubeMetaLoaderFieldType.Index;
    CountryBinding.Dimension := Mb.ItemByIdNamespace("DICT_CTR", NsiDescr.Key).Bind As IDimensionModel;

    // IX_WEO - unique key of the DICT_CTR dictionary
    CountryBinding.Index := "IX_WEO";
    CountryBinding.KeyAttribute := "KEY";
    CountryBinding.NameAttribute := "NAME";
    Filter := CountryBinding.Filter;
    Filter.DeselectAll;
    Indexes := Filter.Dimension.Indexes;
    key := Indexes.PrimaryIndex.LookUp("213");
    Filter.SelectElement(key, False);
    LevelBinding := CubeMetaLoaderBindings.Add;
    LevelBinding.BindingType := CubeMetaLoaderBindingType.Attribute;
    LevelBinding.Attribute := "DL";
    LevelBinding.FieldType := CubeMetaLoaderFieldType.ConstValue;
    LevelBinding.FieldValue := DimCalendarLevel.Year As Integer;
    UnitBinding := CubeMetaLoaderBindings.Add;
    UnitBinding.BindingType := CubeMetaLoaderBindingType.Unit;
    UnitBinding.Field := "Units";
    UnitBinding.FieldType := CubeMetaLoaderFieldType.Index;
    UnitBinding.Field := "2";
    ScaleBinding := CubeMetaLoaderBindings.Add;
    ScaleBinding.BindingType := CubeMetaLoaderBindingType.Unit;
    ScaleBinding.Field := "3";
    ScaleBinding.FieldType := CubeMetaLoaderFieldType.Index;
    ScaleBinding.Dimension := Mb.ItemByIdNamespace("UNITS", NsiDescr.Key).Bind As IDimensionModel;

    // IX_WEO_UNIT_SCALE - unique key of the UNITS dictionary
    ScaleBinding.Index := "IX_WEO_UNIT_SCALE";
    ScaleBinding.KeyAttribute := "KEY";
    CubeMetaLoader.DataOffset := 1;

    // Data provider
    Excel := New DtExcelProvider.Create;
    Excel.ImexMode := DtExcelImexMode.Import;
    Excel.File := "C:\Fixed.xlsx";
    Excel.Query := "SELECT * FROM [Sheet1$]";
    Excel.HasHeader := False;
    Excel.CheckFieldName := False;
    Excel.Open;
    Provider := Excel As IDatasetDataProvider;
    CubeMetaLoader.Data := Provider;
    CubeMetaLoader.LoadData;
    Log := CubeMetaLoader.Log;
    Count := Log.Count;
    Debug.WriteLine("Total records in log: " + Count.ToString);
    For i := 0 To Count - 1 Do
        Entry := Log.Item(i);
        Debug.WriteLine(i.ToString + " : "
            + Entry.DateBegin.ToString + ","
            + Entry.RecordNumber.ToString + ","
            + Entry.Field + ","
            + Entry.ErrorMessage);
        If i >= 10 - 1 Then
            Break;
        End If;
    End For;
End Sub UserProc;

After executing the example the indicators are imported from the specified file. Only the indicators, which COUNTRY attribute is equal to 213, are exported.

See also:

ICubeMetaLoaderBinding