Condition: String;
Condition: String;
The Condition property determines the MDX expression that returns logic value.
The output set will have only the data, for which the specified MDX expression returns True.
Executing the example requires that the repository contains an ADOMD catalog with the ADOMDTest identifier, this catalog contains the SALES ADOMD cube. The cube structure must have dimensions based on ADOMD dictionaries with the DATE and COUNTRY identifiers, facts dimension contains the [Measures].[Reseller Order Count] factor.
Sub UserProc;
Var
Mb: IMetabase;
CubeInst: ICubeInstance;
DestInst: ICubeInstanceDestination;
Sels: IDimSelectionSet;
CubeExecSet: ICubeExecuteSetup;
FilterSetup: ICubeExecuteFilterSetup;
DimSetup: ICubeExecuteDimSetup;
FilterItem: ICubeExecuteFilterItem;
FilterFunction: ICubeExecuteFilterFunction;
Exec: ICubeInstanceDestinationExecutor;
Matr: IMatrix;
Begin
Mb := MetabaseClass.Active;
CubeInst := MB.ItemByIdNamespace("SALES", MB.GetObjectKeyById("ADOMDTest")).Open(Null) As ICubeInstance;
DestInst := CubeInst.Destinations.DefaultDestination;
Sels := DestInst.CreateDimSelectionSet;
CubeExecSet := Sels As ICubeExecuteSetup;
//Get object to set up filtering by dimensions
FilterSetup := CubeExecSet.Filter;
//Distribute dimensions by groups, set selection and dimension filter
For Each DimSetup In CubeExecSet Do
If DimSetup.Id = "DATE" Then
DimSetup.Selection.SelectAll;
DimSetup.GroupIndex := 2; //By rows
FilterFunction := (FilterSetup As ICubeExecuteFilterFunctionFactory).CreatePredefined(CubeExecuteFilterFunctionPredefined.Filter);
(FilterFunction As ICubeExecuteFilterFunctionFilter).Condition := "[Measures].[Reseller Order Count] > 100";
FilterItem := FilterSetup.Add;
FilterItem.Function_ := FilterFunction;
FilterItem.Dimension := DimSetup;
Elseif DimSetup.Id = "COUNTRY" Then
DimSetup.Selection.SelectElement(1, False);
DimSetup.GroupIndex := 1; //By columns
Else
DimSetup.Selection.SelectElement(0, False);
DimSetup.GroupIndex := 0; //Other dimensions into fixed ones
End If;
End For;
//Prepare for calculation
Exec := DestInst.CreateExecutor;
Exec.PrepareExecute(Sels);
//Calculation
Exec.PerformExecute;
//Get matrix with calculation results
Matr := Exec.Matrix;
End Sub UserProc;
On executing the example the specified ADOMD cube is prepared and calculated. On calculation the output data set is filtered according to the set condition: [Measures].[Reseller Order Count] > 100.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Matrix;
Imports Prognoz.Platform.Interop.Metabase;
Public Shared Sub Main(Params: StartParams);
Var
Mb: IMetabase;
CubeInst: ICubeInstance;
DestInst: ICubeInstanceDestination;
Sels: IDimSelectionSet;
CubeExecSet: ICubeExecuteSetup;
FilterSetup: ICubeExecuteFilterSetup;
DimSetup: ICubeExecuteDimSetup;
FilterItem: ICubeExecuteFilterItem;
FilterFunction: ICubeExecuteFilterFunction;
Exec: ICubeInstanceDestinationExecutor;
Matr: IMatrix;
Begin
Mb := Params.Metabase;
CubeInst := MB.ItemByIdNamespace["SALES", MB.GetObjectKeyById("ADOMDTest")].Open(Null) As ICubeInstance;
DestInst := CubeInst.Destinations.DefaultDestination;
Sels := DestInst.CreateDimSelectionSet();
CubeExecSet := Sels As ICubeExecuteSetup;
//Get object to set up filtering by dimensions
FilterSetup := CubeExecSet.Filter;
//Distribute dimensions by groups, set selection and dimension filter
For Each DimSetup In CubeExecSet Do
If DimSetup.Id = "DATE" Then
DimSetup.Selection.SelectAll();
DimSetup.GroupIndex := 2; //By rows
FilterFunction := (FilterSetup As ICubeExecuteFilterFunctionFactory).CreatePredefined(CubeExecuteFilterFunctionPredefined.cuexfifuprFilter);
(FilterFunction As ICubeExecuteFilterFunctionFilter).Condition := "[Measures].[Reseller Order Count] > 100";
FilterItem := FilterSetup.Add();
FilterItem.@Function := FilterFunction;
FilterItem.Dimension := DimSetup;
Elseif DimSetup.Id = "COUNTRY" Then
DimSetup.Selection.SelectElement(1, False);
DimSetup.GroupIndex := 1; //By columns
Else
DimSetup.Selection.SelectElement(0, False);
DimSetup.GroupIndex := 0; //Other dimensions into fixed ones
End If;
End For;
//Prepare for calculation
Exec := DestInst.CreateExecutor();
Exec.PrepareExecute(Sels);
//Calculation
Exec.PerformExecute(False);
//Get matrix with calculation results
Matr := Exec.Matrix;
End Sub;
See also: