Params: IEaxDataAreaParams;
The Params property returns analytical data area slice parameters.
The parameters enable the user to use in formulas not dimension separate elements, but the whole dimensions.
Executing the example requires that the repository contains a regular report with the REPORT identifier. An analytical data area is created in the report, there is a dimension with the REGIONS identifier among source dimensions.
Link the Dal, Dimensions, Express, Metabase, Report system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Report: IPrxReport;
DataArea: IEaxDataArea;
DataAreaSlice: IEaxDataAreaSlice;
DimSS: IDimSelectionSet;
DimS: IDimSelection;
DimInst: IDimInstance;
Hierarchies: IEaxDataAreaHierarchies;
Hierarchy: IEaxDataAreaHierarchy;
CustomDim: ICustomDimension;
Elements: ICustomDimElements;
Attributes: ICustomDimAttributes;
Params: IEaxDataAreaParams;
Param: IEaxDataAreaParam;
Transform: IEaxDataAreaTransformation;
hKey, newElIndex, ElId: Integer;
Begin
MB := MetabaseClass.Active;
Report := MB.ItemById("REPORT").Edit As IPrxReport;
DataArea := Report.DataArea As IEaxDataArea;
DataAreaSlice := DataArea.Slices.Item(0);
//Source dimension
DimSS := DataAreaSlice.Selection;
DimS := DimSS.FindById("REGIONS");
DimInst := DimS.Dimension;
//Analytical data area slice parameters
Params := DataAreaSlice.Params;
//Clearing of parameters list
Params.Clear;
//Adding a new parameter
Param := Params.AddNew;
Param.Hidden := False;
Param.Id := "ID1";
Param.Name := "Test parameter";
Param.LinkedObject := DimInst.MetabaseObject.Object;
Param.DataType := DbDataType.Integer;
Param.DefaultValue := DimInst.Elements.Elements.Element(0);
//Create a calculated element based on the created parameter
Hierarchies := DataArea.Hierarchies;
//Hierarchy unique key
hKey := Hierarchies.CreateKey(DataAreaSlice.Key, DimS.Dimension.Key);
//Get alternative hierarchy by its key
Hierarchy := Hierarchies.FindByKey(hKey);
//If hierarchy is not found by key, create it
If Hierarchy = Null Then
Hierarchy := Hierarchies.Add(DataAreaSlice, DimS, hKey);
End If;
//Get facts dimension
CustomDim := Hierarchy.CustomDimension;
//Get elements and indexes of fact dimension attributes
Elements := CustomDim.Elements;
Attributes := CustomDim.Attributes;
//Creating a new element
newElIndex := Elements.Add;
ElId := Elements.RowCount + 1;
//Attribute values for new element
Elements.AttributeValueByKey(newElIndex, Attributes.Name.Key) := "Calculated element";
Elements.AttributeValueByKey(newElIndex, Attributes.Id.Key) := ElId.ToString;
Elements.AttributeValueByKey(newElIndex, Attributes.Order.Key) := ElId;
//Applying of changes to dimension with alternative hierarchy
Hierarchies.PushChangesToDimInstance(DimS, CustomDim);
newElIndex := DimS.Dimension.Elements.FindById(ElId.ToString);
//Transformation formula for calculated element
Transform := DataAreaSlice.CalcTransformations.Add(DimSS, DimS, newElIndex);
Transform.Enabled := True;
Transform.Expression.AsString := '{' + Param.Id + '}';
Hierarchies.AddDependant(DimS, hKey, DimSS, ElId.ToString, Transform);
//Saving
Report.MetabaseObject.Save;
End Sub UserProc;
On executing the example the analytical data area slice is extended:
A parameter referring to the REGIONS dimension is added.
An alternative hierarchy with added calculated element is created for the REGIONS dimension.
A transformation formula based on the created parameter is set for the calculated element.
See also: