DeepSee MDX Reference
CURRENTMEMBER
[Back] [Next]
   
Server:docs2
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Enables you to refer to a member programmatically within an iteration through the members of a hierarchy.
Returned Type
This function returns a member.
Syntax and Details
hierarchy_expression.CURRENTMEMBER
dimension_expression.CURRENTMEMBER
You use this function in a context that iterates through a hierarchy. The CURRENTMEMBER function returns the given member, in that context.
In abstract, this function has the same purpose as does $this in Caché ObjectScript.
Note:
The CURRENTMEMBER function is not supported with the MEASURES dimension. That is, dimension_expression cannot be MEASURES.
Example
In the following example, cities are used as rows. The data shown in the column is the Principal Export property for each city, retrieved via the PROPERTIES function.
SELECT homed.CURRENTMEMBER.PROPERTIES("Principal Export") ON 0, homed.city.MEMBERS ON 1 
FROM patients

                                  Home ZIP
1 Cedar Falls                          iron
2 Centerville                   video games
3 Cypress                            gravel
4 Elm Heights                       lettuce
5 Juniper                             wheat
6 Magnolia                       bundt cake
7 Pine                            spaghetti
8 Redwood                           peaches
9 Spruce                                mud
The following variation uses the %LABEL function to provide a better caption for the data column:
SELECT %LABEL(homed.CURRENTMEMBER.PROPERTIES("Principal Export"),"Exports") ON 0, 
homed.city.MEMBERS ON 1 FROM patients

                                    Export
1 Cedar Falls                          iron
2 Centerville                   video games
3 Cypress                            gravel
4 Elm Heights                       lettuce
5 Juniper                             wheat
6 Magnolia                       bundt cake
7 Pine                            spaghetti
8 Redwood                           peaches
9 Spruce                                mud
The following query shows both the Principal Export and Population properties of the City level:
SELECT {%LABEL(homed.CURRENTMEMBER.PROPERTIES("Principal Export"),"Export"),
%LABEL(homed.CURRENTMEMBER.PROPERTIES("Population"),"Population")} ON 0, 
homed.city.MEMBERS ON 1 FROM patients

                              Export           Population
1 Cedar Falls                    iron               90,000
2 Centerville             video games               49,000
3 Cypress                      gravel                3,000
4 Elm Heights                 lettuce               33,194
5 Juniper                       wheat               10,333
6 Magnolia                 bundt cake                4,503
7 Pine                      spaghetti               15,060
8 Redwood                     peaches               29,192
9 Spruce                          mud                5,900