@ENUMVALUE

The @ENUMVALUE calculation function for Essbase returns the internal numeric value for a text value in a text list.

Syntax

@ENUMVALUE ([mbrName,]enum_string)

Parameters

mbrName

Optional. Any valid single member name, or a function that returns a single member. If given as the first argument, @ENUMVALUE checks the text list associated with that member, and returns the numeric value of the character string provided in the second argument.

enum_string

If mbrName is given as the first argument, this is a char_string_literal of one of the text strings represented in the text list.

If no mbrName is given as first argument, this is a string of the format text_list_name, char_string_literal, where:

  • text_list_name is the name of a text list, or of a member that is associated with a text list.

  • char_string_literal is one of the text values represented in the text list.

Example

The following examples are based on the Facility Rating cube, which you can download from the Files catalog under All Files > Gallery > Applications > Facility Rating. The cube includes a text list named ResponseValues that has the following mappings: "Perfect" = 1, "Very Nice" = 2, "Nice" = 3, "Good some of the times" = 4, "No Opinion" = 5.

Example 1a: Using @ENUMVALUE in a member formula

The following example formula means: For every "Answer" to every "Office" within the Geography of "USA", change the "Answer" to "Good some of the times" if the current "Answer" is "No Opinion".

FIX (@IDESCENDANTS("USA"))
"Office" (
    IF ("Answer" == @ENUMVALUE("ResponseValues", "No Opinion"))
        "Answer" = @ENUMVALUE("ResponseValues", "Good some of the times");
    ENDIF
);
ENDFIX

Example 1b: Using the text list’s numeric values in a member formula

The following example formula does the same thing as the one in Example 1a, but this use case is not recommended. It is less error-prone to use @ENUMVALUE to look up the value from the text list. In the example below, the calculation script will validate even if the assignment statement would lead to an out of range response value (a value not mapped in the ResponseValues text list object).

FIX (@IDESCENDANTS("USA"))
"Office" (
    IF ("Answer" == 5)
        "Answer" = 4;
    ENDIF
);
ENDFIX