Count: Integer;
The Count property returns the number of filters in the collection.
Executing the example requires that the repository contains a time series database with the FC identifier. The modeling container of this database must include a model with the MODEL_AGGR identifier calculated using extended aggregation method. COUNTRY is the attribute of database time series that refers to the dictionary.
Add links to the Cubes, Dimensions, Metabase, Ms, Rds system assemblies.
Sub Main;
Var
mb: IMetabase;
RubrDescr: IMetabaseObjectDescriptor;
Rubr: IRubricator;
msDescr: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
Formula: IMsFormula;
Aggr: IMsCrossDimensionAggregationTransform;
FiltesList: IMsAggregationFilterList;
Filter: IMsAggregationFilter;
i: Integer;
Attributes: IMetaAttributes;
DictDescr: IMetabaseObjectDescriptor;
FilterDimension: IMetabaseObject;
DimInst: IDimInstance;
Selection: IDimSelection;
Begin
mb := MetabaseClass.Active;
RubrDescr := mb.ItemById("FC");
Rubr := RubrDescr.Bind As IRubricator;
msDescr := Rubr.ModelSpace;
Model := mb.ItemByIdNamespace("MODEL_AGGR", msDescr.Key).Edit As IMsModel;
Transform := Model.Transform;
Formula := Transform.FormulaItem(0);
Aggr := Formula.Method As IMsCrossDimensionAggregationTransform;
FiltesList := Aggr.Filter;
Attributes := Rubr.Facts.Attributes;
DictDescr := Attributes.FindById("COUNTRY").ValuesObject;
Filter := FiltesList.Add(DictDescr.Bind As IDimensionModel);
FilterDimension := Filter.FilterDimension As IMetabaseObject;
DimInst := FilterDimension.Open(Null) As IDimInstance;
Selection := DimInst.CreateSelection;
For i := 0 To 5 Do
Selection.SelectElement(i, False);
End For;
Filter.AggregationSelection := Selection;
Debug.WriteLine("AGGREGATION FILTERS");
For i := 0 To FiltesList.Count - 1 Do
Filter := FiltesList.Item(i);
Debug.WriteLine(" Filter name: " + Filter.Name);
Debug.WriteLine(" Filter selection: " + Filter.AggregationSelection.ToString);
End For;
(Model As IMetabaseObject).Save;
End Sub;
After executing the example the collection of extended aggregation model filters is cleared. Then the new filter is added to the collection: calculate aggregation only for first six elements of the dictionary, to which the COUNTRY attribute refers. After that information about all model filters is displayed in the console window.
See also:
Related work items
Requirement 130645