I am trying to add a calculated member to an MDX query which will create a set of "Age Bands" for people in my database. I have a measure which contains the age of each person.
I have started with this MDX
SELECT
NON EMPTY {[Measures].[Count of People]} ON COLUMNS,
NON EMPTY {
(
[People].[Gender].[Gender],
[People].[Some].[Other Attributes]
)
} ON ROWS
FROM [MyCube]
WHERE ( ... slicer here .... )
I have another measure ([Measures].[Age]
) which I would like to band up and return with the rows, so eg anyone aged 0-25, 26-50 etc
Here is what Ive tried
WITH SET [Age Band]
AS IIF([Measures].[Age]<26,"0-26",IIF([Measures].[Age]<51,"26-51","Over 50"))
SELECT
NON EMPTY {[Measures].[Count of People]} ON COLUMNS,
NON EMPTY {
(
[People].[Gender].[Gender],
[People].[Some].[Other Attributes],
[Age Band]
)
} ON ROWS
FROM [MyCube]
WHERE ( ... slicer here .... )
However the error I get is
The function expects a tuple set expression for the argument. A string or numeric expression was used.
What am I doing wrong? Is there an easier/better way to do this without chaining IIF
commands?