Using MDX Parameters in Report Builder 2.0
-
11-09-2019 - |
Question
I currently have a query that looks like this:
SELECT
NON EMPTY ([Measures].[TOTAL]) ON 0,
NON EMPTY (([ENROLL DATE].[CALENDAR].[YEAR].["
+ Parameters!EnrollDate.Value +
"] * [DIM ENROLLMENT].[ENROLLMENT].[ENROLLMENT PROG].ALLMEMBERS)) ON 1
FROM (SELECT (([DIM ENROLLMENT].[ENROLLMENT].[TERMINATION REASON].[Still Enrolled])) ON 0 FROM [NapaCHI]);
The bold section comes from the parameters section where I manually specified the parameters with Label = 2006 and Value = 2006
. I have tried just about every acceptable syntax and read about every article about this and cannot seem to get it to work whether I define the values myself or use a separate MDX statement that selects distinct non-empty years and (NULL) for the aggregate.
Help please, it's driving me insane! Thanks.
Solution
Your expression looks incomplete, you would need to start it with and = sign and quote it propertly. Something like the following
="SELECT
NON EMPTY ([Measures].[TOTAL]) ON 0,
NON EMPTY (([ENROLL DATE].[CALENDAR].[YEAR].[" + Parameters!EnrollDate.Value + "] * [DIM ENROLLMENT].[ENROLLMENT].[ENROLLMENT PROG].ALLMEMBERS)) ON 1
FROM (SELECT (([DIM ENROLLMENT].[ENROLLMENT].[TERMINATION REASON].[Still Enrolled])) ON 0 FROM [NapaCHI]);"
You may also have issues with datatypes, you might want to either use the .Label property of the parameter or explicitly convert the value to a string. If none of this works it would be helpful to know what error you are getting.
OTHER TIPS
I think this MDX is requiring:
NON EMPTY (([ENROLL DATE].[CALENDAR].[YEAR].[Calendar " + Parameters!EnrollDate.Value + "]
Or you could you the actual MDX language like so:
[ENROLL DATE].[CALENDAR].[YEAR].&[" + Parameters!EnrollDate.Value + "-01-01T00:00:00]
Either of those should work.