IDimSelection.AttributeToVariantOI

Fore Syntax

AttributeToVariantOI(Attribute: IDimAttribute): Variant;

Fore.NET Syntax

AttributeToVariantOI(Attribute: Prognoz.Platform.Interop.Dimensions.IDimAttribute): object;

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.

Fore 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 executed by an attribute with the KEY_ identifier.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore Example. Use Fore.NET analogs instead of Fore components.

Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Express;
Imports Prognoz.Platform.Interop.Pivot;

Public Shared Sub Main(Params: StartParams);
Var
    Mb: IMetabase;
    Express: IEaxAnalyzer;
    Selection: IDimSelection;
    H_Inst: IDimHierarchyInstance;
    Attrs: IDimAttributesInstance;
    Attr, A_Attr: IDimAttributeInstance;
    Origin_Attr, Alt_Attr: IDimAttribute;
    PreSchema: IPredefinedSelectionSchema;
    v: object;
Begin
    // Get repository
    Mb := Params.Metabase;
    // 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);
    System.Diagnostics.Debug.WriteLine("Custom hierarchy selection:" + Selection.ToString("NAME"";"False));
    // Change dimension selection schema
    PreSchema := Selection.PredefinedSchema;
    // Select all elements
    If (PreSchema <> NullThen
        If (PreSchema.Count = 0Then
            PreSchema.Add(SelectionPrimitiveType.sptAll);
        End If;
        // Use predefined dimension selection schema
        PreSchema.Active := True;
    End If;
    // Save report
    System.Diagnostics.Debug.WriteLine("Selection after change:" + Selection.ToString("NAME"";"False));
    (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, False);
    System.Diagnostics.Debug.WriteLine("Selection after restore:" + Selection.ToString("NAME"";"False));
    // Save report
    (Express As IMetabaseObject).Save();
End Sub;

See also:

IDimSelection