Skip to main content

LOOKUP (MDX)

Looks up a given key in a term list and returns a substitute string. This function enables you to perform string replacements within a query. This function is an InterSystems extension to MDX.

Returned Type

This function returns a string.

Syntax and Details

LOOKUP(term_list_name, lookup_value,default,alternative_field)

Where the arguments are string expressions as follows:

  • term_list_name evaluates to the name of a term list.

  • lookup_value evaluates to the string to look up in the term list.

  • default, which is optional, evaluates to the value to return if lookup_value is not found in the term list.

  • alternative_field, which is optional, is the name of the field to return. The default is "value".

    This argument is not case-sensitive.

This function examines the given term list, finds the term whose "key" field equals the string given by lookup_value and then returns the value contained in the field identified by alternative_field.

All term lists have at least two fields: "key" and "value". You can add additional fields. For information, see Defining Term Lists

The system notes the most recent modification time stamp of any term list and invalidates any query cache that uses an outdated term list.

Example

For example, suppose that for HoleFoods, we have a term list named Teams that is defined as follows:

generated description: term list teams

Here is a simple query that uses this term list:

SELECT Lookup("Teams",Outlet.Boston.Properties("NAME")) ON ROWS FROM HOLEFOODS
  
Lookup                              Red Sox

Here is a more complex query:

SELECT Lookup("Teams",Outlet.CURRENTMEMBER.Properties("NAME"),"No Team") ON 0, 
outlet.city.MEMBERS ON 1 FROM HOLEFOODS
 
                                    Lookup
 1 Amsterdam                        No Team
 2 Antwerp                          No Team
 3 Atlanta                           Braves
 4 Bangalore                        No Team
 5 Barcelona                        No Team
 6 Beijing                          No Team
 7 Berlin                           No Team
 8 Boston                           Red Sox
 9 Brasilia                         No Team
...

See Also

FeedbackOpens in a new tab