IDimSelection.AttributeToVariantOI

Syntax

AttributeToVariantOI(Attribute: IDimAttribute): Variant;

Parameters

Attribute. The dictionary attribute, which values are used to form selection. A unique index must be created in the dictionary by this attribute.

Description

The AttributeToVariantOI method forms selection value by values of the specified element attribute, if a link between a custom hierarchy and a source dictionary is set.

Comments

If the link between the custom hierarchy and the source dictionary is not set, selection values are taken from the source dictionary.

Custom hierarchy is an alternative hierarchy created in the report on adding an element to a dimension.

Example

Executing the example requires that the repository contains an express report with the DS_PA identifier containing a custom hierarchy.

Add links to the Dimensions, Express, Metabase, Pivot system assemblies.

Sub UserProc;
Var
    Mb: IMetabase;
    Express: IEaxAnalyzer;
    Selection: IDimSelection;
    H_Inst: IDimHierarchyInstance;
    Attrs: IDimAttributesInstance;
    Attr, A_Attr: IDimAttributeInstance;
    Origin_Attr, Alt_Attr: IDimAttribute;
    PreSchema: IPredefinedSelectionSchema;
    v: Variant;
Begin
    // Get repository
    Mb := MetabaseClass.Active;
    // Get express report
    Express := MB.ItemById("DS_PA").Edit As IEaxAnalyzer;
    // Get selection of the Territories dimension
    Selection := Express.Pivot.Selection.Item(3);
    H_Inst := Selection.Hierarchy;
    Attrs := H_Inst.Source.Attributes;
    Attr := Attrs.FindById("KEY_");
    Origin_Attr := Attr.Attribute;
    v := selection.AttributeToVariantOI(Origin_Attr);
    Debug.WriteLine("Custom hierarchy selection:" + Selection.ToString);
    // Change dimension selection schema
    PreSchema := Selection.PredefinedSchema;
    // Select all elements
    If (PreSchema <> NullThen
        If (PreSchema.Count = 0Then
            PreSchema.Add(SelectionPrimitiveType.All);
        End If;
        // Use predefined dimension selection schema
        PreSchema.Active := True;
    End If;
    // Save report
    Debug.WriteLine("Selection after change:" + Selection.ToString);
    (Express As IMetabaseObject).Save;
    // Get express report
    Express := MB.ItemById("DS_PA").Edit As IEaxAnalyzer;
    // Get selection of the Territories dimension
    Selection := Express.Pivot.Selection.Item(3);
    // Restore selection
    H_Inst := Selection.Hierarchy;
    Attrs := H_Inst.Source.Attributes;
    A_Attr := Attrs.FindById("KEY_");
    Alt_Attr := Attr.Attribute;
    Selection.ParseAttributeOI(v, Alt_Attr);
    Debug.WriteLine("Selection after restore:" + Selection.ToString);
    // Save report
    (Express As IMetabaseObject).Save;
End Sub UserProc;

After executing the example the custom hierarchy selection is taken in the express report, then the selection is changed and at last restored. The console window displays the custom hierarchy selection elements, selected elements after the selection is changed, and elements after the selection is restored. Transformations are carried out by the attribute with the KEY_ identifier.

See also:

IDimSelection