@ENUMVALUE
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
Example 1, No Member Name
The following example is based on a variation of ASOSamp.Sample. Assume there is a text list named CustSatRatings, in which text values are mapped to numeric IDs as follows: Good=1, Average=2, Poor=3.
@ENUMVALUE(CustSatRatings, "Good");
The above example returns 1
.
Example 2, with Member Name
The following calculation example performs a conditional test and assigns a value to Profit depending on the test results. A calculation script is used to set the member named SmartText with the text string "RED":
SET CREATENONMISSINGBLK ON;
FIX ("100-10", California, Actual, Oct)
SmartText = "RED";
ENDFIX;
A member formula on Profit causes the value of Profit to depend on the following conditional test: if the internal numeric value of member SmartText is associated with the text string "RED", the value of Profit will be set to 99.
Profit (IF(@EnumValue(SmartText, "RED") == SmartText )
Profit=99;
The conditional test returns true, and the value of Profit is set to 99.