In this post, I will show you how you can make nice indented report parameters in SSRS. This might become handy if you want to display multiple levels in the same parameter list.
Let’s start by writing a simple MDX to list the years and week numbers.
WITH MEMBER [RSValue] AS [Date].[Production].CurrentMember.UniqueName MEMBER [RSCaption] AS [Date].[Production].CurrentMember.NAME SELECT { [Measures].[RSValue], [Measures].[RSCaption] } ON 0, DESCENDANTS( [Date].[Production].[Year], [Date].[Production].[Week], SELF_AND_BEFORE ) ON 1 FROM [Adventure Works Internet Sales Model]
Running this query will produce a result like this in SSMS
To add this result to a parameter I will first have to create a dataset. Let’s call that “MyDate”. Then paste the MDX into it. Then assign the “Available Values” as in the screenshot below.
During the report preview, the report parameter will look like this
Not too nice and readable I guess. I really need to make some kind of indenting here. So I start to make some changes to my MDX like this
WITH MEMBER [RSValue] AS [Date].[Production].CurrentMember.UniqueName MEMBER [Indent] AS [Date].[Production].CurrentMember.LEVEL_NUMBER - 1 MEMBER [RSCaption] AS SPACE([Measures].[Indent] * 5) + " " + [Date].[Production].CurrentMember.NAME SELECT { [Measures].[RSValue], [Measures].[Indent], [Measures].[RSCaption] } ON 0, DESCENDANTS( [Date].[Production].[Year], [Date].[Production].[Week], SELF_AND_BEFORE ) ON 1 FROM [Adventure Works Internet Sales Model]
It’s not easy to see the result of this indenting if you run the query in SSMS. But if you replace the query in the dataset we called “MyDate” you will see a much nicer list.
Make sure you trim your parameter when setting it against the dataset you want to filter
Voila!