IExportRequestParams.ValueFilters

Syntax

ValueFilters: ICubeMetaExporterFilters;

Description

The ValueFilters property determines filtering parameters for exported time series by observation attributes.

Comments

To limit the number of exported rows, use the IExportRequestParams.RowCount property.

Example

Executing the example requires a time series database with the TSDB identifier. This database must contain a time series attribute with the CITY identifier that refers to a dictionary.

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

Sub UserProc;
Var
    TextConsumer: IDtTextConsumer;
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    ObjDesc, TSDBDescr: IMetabaseObjectDescriptor;
    Obj: IMetabaseObject;
    ExportRequestDef: IExportRequestDefinition;
    Params: IExportRequestParams;
    Binding: ICubeMetaExporterBinding;
    Filter: ICubeMetaExporterFilter;
    ExportRequestInst: IExportRequestInstance;
Begin
    // Create a data consumer for export to text file
    TextConsumer := New DtTextConsumer.Create;
    TextConsumer.File := "C:\result.txt";
    TextConsumer.FormatType := DtTextFormatType.Delimited;
    TextConsumer.DelimitedColumnDelimiter := ";";
    TextConsumer.DelimitedTextQualifier := """";
    TextConsumer.Encoding := "WIN";
    TextConsumer.WriteHeader := True;
    // Get current repository
    MB := MetabaseClass.Active;
    // Get time series database
    TSDBDescr := MB.ItemById("TSDB");
    // Create an export object  
    CrInfo := MB.CreateCreateInfo;
    CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_EXPORTREQUEST;
    CrInfo.Id := MB.GenerateId("OBJ_EXPORTREQUEST", TSDBDescr.Key);
    CrInfo.Permanent := True;
    CrInfo.Parent := TSDBDescr.Bind;
    ObjDesc := MB.CreateObject(CrInfo);
    Obj := ObjDesc.Edit;
    ExportRequestDef := Obj As IExportRequestDefinition;
    // Get export parameters
    Params := ExportRequestDef.Exporter;
    // Specify data source and data consumer
    Params.Rubricator := MB.ItemById("TSDB").Bind As IRubricator;
    Params.Consumer := TextConsumer As IDtConsumer;
    // Specify that file must be cleared before export
    Params.ClearBeforeExport := True;
    // Add CITY series attribute binding
    Binding := Params.Bindings.Add;
    Binding.FieldName := "City_Name";
    Binding.DataType := DbDataType.String;
    Binding.BindingType := CubeMetaExporterBindingType.Attribute;
    Binding.Attribute := "CITY";
    Binding.KeyField := "NAME";
    // Add CMT observation attribute binding
    Binding := Params.Bindings.Add;
    Binding.FieldName := "CMT";
    Binding.DataType := DbDataType.String;
    Binding.BindingType := CubeMetaExporterBindingType.ValueAttribute;
    Binding.Attribute := "CMT";
    // Add a calendar binding
    Binding := Params.Bindings.Add;
    Binding.FieldName := "Year";
    Binding.DataType := DbDataType.String;
    Binding.BindingType := CubeMetaExporterBindingType.Calendar;
    Binding.DateFormat := "$Year$";
    Binding.ValueFieldName := "Value";
    Binding.ValueDataType := DbDataType.Float;
    // Set filtering parameters for exported series
    // Add filtering by CMT observation attribute values
    Filter := Params.ValueFilters.Add;
    Filter.Attribute := "CMT";
    // Specify that attribute values must not be empty
    Filter.Operator_ := OrmComparisonOperator.IsNotNull;
    // Save export object
    Obj.Save;
    // Execute export
    ExportRequestInst := (ExportRequestDef As IMetabaseObjectDescriptor).OpenWithParam(NullAs IExportRequestInstance;
    ExportRequestInst.Export;
End Sub UserProc;

After executing the example only the series containing CMT observation attribute value are exported to the C:\result.txt file.

See also:

IExportRequestParams