Question
· Jan 13, 2021

MDX - How to return a member from a set?

How do we return a member from a set?  For example if I want a calculated measure to return the NAME of the date with the max transactions, to get the set ordered I might do something like:

ORDER([TransactionDate].[YearMonthDate].[Date].MEMBERS, [Measures].[TransactionCount], DESC)

But how do I access the first member in the set as a member so that I can get to the properties such as the member NAME (what I want to return in this case)?

In some MDX implementations like Microsoft there are kind of backdoor functions for this like:

ORDER([TransactionDate].[YearMonthDate].[Date].MEMBERS, [Measures].[TransactionCount], DESC).item(0).item(0).Properties("NAME")

where the "item(0)" lets you reference individual members within a set.  What is the way to achieve this functionality in IRIS?

Product version: IRIS 2020.1
Discussion (4)1
Log in or sign up to continue

HEAD returns a set, even if that set only has one member in it.  You will not be able to use the result of HEAD as an argument to a function that takes a member argument.  Some MDX implementations use some sort of iterator function that allows selecting the nth member of a set (e.g. Microsoft uses an "item()" function).  It sounds like there may not be something like that in IRIS MDX.