KeyUnique: Boolean;
The KeyUnique property determines attribute which checks that selection keys included in collection are unique.
Available values:
True. On adding a new dictionary in the collection, there is a check that it is present in selection. If dictionary is added, there will be no new adding.
False. On adding a new dictionary in the collection, there is no check whether it is present in selection.
If the property is set to False, it helps to add the same dictionary to the collection several times. It can be necessary if the same dictionary will be used with several alternative hierarchies. Such behavior is used on working with the ADOMD cubes.
Executing the example requires that repository contains the ADOMD directory with the ADOMDTest identifier and in the directory there is the ADOMD cube - «SALES». In cube structure there is a dimension based on the ADOMD dictionaries with the PRODUCTS identifiers for which several alternative hierarchies are created.
Sub UserProc;
Var
MB: IMetabase;
CubeInst: ICubeInstance;
Dest: ICubeInstanceDestination;
SelSet: IDimSelectionSet;
Sel, Sel2: IDimSelection;
Hiers: IDimHierarchiesInstance;
DimSetup: ICubeExecuteDimSetup;
Exec: ICubeInstanceDestinationExecutor;
AdoExec: IAdoMdCubeExecutor;
Mat: IMatrix;
Begin
MB := MetabaseClass.Active;
CubeInst := MB.ItemByIdNamespace("SALES", MB.GetObjectKeyById("ADOMDTest")).Open(Null) As ICubeInstance;
Dest := CubeInst.Destinations.DefaultDestination;
SelSet := Dest.CreateDimSelectionSet;
//Cancel check that selections are unique
(SelSet As IDimSelectionSet2).KeyUnique := False;
//Dimension selection
Sel := SelSet.FindById("PRODUCTS");
//Alternative hierarchies
Hiers := Sel.Dimension.Hierarchies;
//Adding of dimension selection one more time
Sel2 := SelSet.Add(Sel.Dimension);
//Set up alternative hierarchy for the second instance of dimension selection
Sel2.Hierarchy := Hiers.FindByKey(6);
//Set up selections
For Each Sel In SelSet Do
If Sel.Dimension.Ident = "PRODUCTS" Then
Sel.SelectAll;
DimSetup := CubeClass.SelectionSetup(Sel);
If DimSetup <> Null Then
DimSetup.GroupIndex := 1;
End If;
Else
Sel.SelectElement(1, False);
DimSetup := CubeClass.SelectionSetup(Sel);
If DimSetup <> Null Then
DimSetup.GroupIndex := 2;
End If;
End If
End For;
//Calculation
Exec := Dest.CreateExecutor;
AdoExec := Exec As IAdoMdCubeExecutor;
Exec.PrepareExecute(SelSet);
Exec.PerformExecute;
Mat := Exec.Matrix;
End Sub UserProc;
On executing the example preparation and calculation of the specified ADOMD cube will be performed. On preparing selection for calculation, the PRODUCTS dimension will be included twice in selection collection. Alternative hierarchy will be applied for the second instance. Selection for each instance of the PRODUCTS dimension will be set to maximum. Calculation result will be available in the Mat variable.
See also: