ICubeMetaExporterFilter.Selection

Syntax

Selection: IDimSelection;

Description

The Selection property determines the selection of elements of the dictionary linked with the attribute, by which it is necessary to filter time series.

Comments

After setting value of the ICubeMetaExporterFilter.Attribute or ICubeMetaExporterFilter.AttributeKey property the Selection property enables the user to set empty selection of the dictionary, to which the attribute refers. After getting and setting the selection it is necessary to reassign the value of the Selection property.

Example

Executing the example requires that the repository contains a time series database with the TSBD identifier. A mandatory time series attribute with the CITY identifier is created in the database structure. This attribute refers to the dictionary.

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

Sub UserProc;
Var
    MB: IMetabase;
    TextConsumer: IDtTextConsumer;
    Exporter: ICubeMetaExporter;
    Binding: ICubeMetaExporterBinding;
    Filter: ICubeMetaExporterFilter;
    DictSelection: IDimSelection;
Begin
    MB := MetabaseClass.Active;
    //Create a data consumer for export to text format
    TextConsumer := New DtTextConsumer.Create;
    TextConsumer.File := "C:\export_result.txt";
    TextConsumer.FormatType := DtTextFormatType.Delimited;
    TextConsumer.DelimitedColumnDelimiter := ";";
    TextConsumer.DelimitedTextQualifier := "";
    TextConsumer.Encoding := "WIN";
    TextConsumer.WriteHeader := True;
    // Create an object for time series export
    Exporter := New CubeMetaExporterClass.Create;
    Exporter.Rubricator := MB.ItemById("TSDB").Bind As IRubricator;
    Exporter.Consumer := TextConsumer As IDtConsumer;
    // Set export parameters for the CITY attribute
    Binding := Exporter.Bindings.Add;
    Binding.FieldName := "CITY_KEY";
    Binding.DataType := DbDataType.Integer;
    Binding.BindingType := CubeMetaExporterBindingType.Attribute;
    Binding.Attribute := "CITY";
    Binding.KeyField := "KEY";
    // Set calendar export parameters
    Binding := Exporter.Bindings.Add;
    Binding.FieldName := "Year";
    Binding.DataType := DbDataType.String;
    Binding.BindingType := CubeMetaExporterBindingType.Calendar;
    Binding.DateFormat := "$Year$";
    // Set export parameters
    Exporter.ByColumns := False;
    Exporter.CalendarLevel := DimCalendarLevel.Year;
    Exporter.ClearBeforeExport := True;
    // Add a filter for time series export
    Filter := Exporter.Filters.Add;
    // Specify the attribute, by which time series are filtered
    Filter.Attribute := "CITY";
    // Get selection of elements the dictionary linked with the specified attribute
    DictSelection := Filter.Selection;
    // Select the first element in dictionary
    DictSelection.SelectElement(0False);
    // Set the specified selection for time series filtering
    Filter.Selection := DictSelection;
    // Execute export
    Exporter.Export;
End Sub UserProc;

On executing the example time series values are exported to text file. The exported time series are filtered: export is executed only by the first dictionary element, with which the CITY attribute is linked.

See also:

ICubeMetaExporterFilter