Parent-Child hierarchies in Reporting Services
Reporting Services 2008 is a great reporting tool, but displaying Analysis Services data with Reporting Services doesn’t always display the data as you would expect.
A Parent-child hierarchy is one example of this: When you browse Parent-child hierarchy from an Analysis Services cube with Excel, Excel automatically displays it with nice drill-down functionality.
But when you add it to a Reporting Services report, you get something like this:
That’s not how we like to display a Parent-Child hierarchy to our users!
To display it with the expected drill-down you need to do some extra configuration:
The following example uses the AdventureWorks example cube available on CodePlex:
Create a new report and add a dataset with the following MDX query:
SELECT NON EMPTY { [Measures].[Amount] } ON COLUMNS,
NON EMPTY { (DESCENDANTS([Organization].[Organizations].[Organization Level 01].ALLMEMBERS) ) }
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME, PARENT_UNIQUE_NAME,
LEVEL_NUMBER ON ROWS
FROM [Adventure Works]
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING,
FONT_NAME, FONT_SIZE, FONT_FLAGS
Add a Tablix to your report and drag the parent-child hierarchy “Organizations” en the fact “Amount” to the Detail Row of the Tablix.
To enable drill-down you need to edit the Group Properties of the Row Group:
Configure the group to iterate on the UniqueName of “Organizations”:
Go to the Advanced options and set the property “Recursive Parent” to the ParentUniqueName of “Organizations”.
Change the visibility of this Group to “Hide” and check the option “Display can be toggled by this report item”. The toggle item should be the Textbox containing the Parent-Child hierarchy.
Now optimize the layout by increasing the indent for the lower levels of the hierarchy:
In the Textbox properties: set the following expression for “Padding – Left”:
=Cstr(Fields!Organizations.LevelNumber * 10) & “pt”
Click Preview to test the report.
Look’s way better isn’t it?
I tried but did not get the same result. The text was indented but the small click box could not be indented.
@Yun Chen
Did you got chance to get resolution on indenting the +/- expander/collapser controlles in the hierarchical report?
Thanks in advance.
-Pritam
Please install SP1 to fix this issue.
Great article! You really got me out of a jam as there really isn’t much info on this topic.
Awesome… You’re my Hero
Nice one Davy, works perfectly!
BTW: if you don’t want the top-level item to jump in that much, change the Padding-Left expression to:
=Cstr((Fields!Organizations.LevelNumber * 10)-8) & “pt”
Good one. Its really help me a lot. Thanks.
Regards,
Shyam
Hi Davy,
Have you ever tried to control the toggle state of a recursive item independently? That is, can we elect to expand or collapse individual levels based on a data-driven element, such as a boolean Expanded field passed in the data? I attempted this without any luck. I also tried using level comparisons within the scope of the group but since there is only one group visibility setting, if you want to collapse a level you unfortunately have to make it invisible (which means you’ll never have an opportunity to expand it) so that doesn’t work. Thanks for your posts and keep up the good work!
Anthony
I don’t think this is possible.
Thank you very much. It works for me.
Saludos
Thank you! This post has restored my faith in SSRS and Report Builder 3.0! Why was this information so hard to find?
Hi Davy,
I have doubt please clarify me , i have created cube on adventure works db
i sorted month wise and deployed it when i am creating Report on top of Cube by draging month name its working fine (sorting like Jan,Feb,Mar)
but when apply grouping to month name its not coming in sorted , how to get in month wise sorted order ?
Please help me
Regards
Sree
Thanks Davy !! Works a treat.
rgds
Thanks for this great article. I was searching for something like this.