Pre-requisites for this article:
- SQL Server 2008 along with SSRS installed
- Business Intelligence Development Studio (BIDS)
- AdventureWorksDW2008R2 database. Click here to install this database from codeplex.
- Familier with SSRS
STEP 1: To begin, create new report in your existing solution. Add new Shared Data Source. If you don't know how to create a shared data source, click Creating Shared Data Source in SSRS 2008.
In Dataset Properties window, enter dsMain in Name textbox and below T-SQL code in Query textbox:
SELECT [EmployeeKey],[ParentEmployeeKey
,[FirstName] + ' ' + ISNULL([MiddleName],'') + ' ' + [LastName] EmployeeName],[Title]
FROM [AdventureWorksDW2008R2].[dbo].[DimEmployee]
STEP 3: Drag and drop Table control and map with dsMain dataset. Select EmployeeName in first column, Title in second column and =Level() expression in the third column. Set following properties for table control:
- Header Background color = DarkBlue
- Header Color = White
- Font = Verdana, 8pt
STEP 4: Set Group Properties to reference Recursive Parent. Select table control --> click View and check Grouping as shown below:
Open Row Group properties, click on add button and select [EmployeeKey] in Group on box.
Click on Advance tab of Group Properties window and select [ParentEmployeeKey] in Recursive parent box. Click OK and save changes.
Here, you can see the Employee Hierarchy but not as per standard. We need to format the text to make it better report. Do below formating for EmployeeName textbox:
1) Enter below expression in FontWeight under Font Property:
=IIF(Count(Fields!EmployeeName.Value, "Details", Recursive) > 1, "Bold", "Normal")
2) Enter below expression in LeftIndent under Indent Property:
=CStr(2 + (Level()*20)) + "pt"
Again Preview the report, report will look like below image:
Cheers!!!
This comment has been removed by the author.
ReplyDeleteTHANK YOU THANK YOU THANK YOU!
ReplyDeleteI was struggling with this for hours and after finding your post I had it working in minutes!
Much appreciated.
Do you think we can make this as collapse and expand?
ReplyDeleteThanks very much. It's easlier than write new store procedure
ReplyDeletehello, i have a similar case but not with customers but with Accounting Items where they have Sale Prices etc.. and i needed to show also a total of each group ,i am really struggling into this for 2 days almost .
ReplyDeletein your example: Roberto must have a TOTAL ROW
TERRY LEE Must have a TOTAL ROW including Roberto and separate ,then DAVID must have a Total Row, How am i going to do all this grouping with N Level Hierarchy
Thanks a ton! mate.
ReplyDeleteHello,
ReplyDeleteI have created recursive ssrs report successfully, I want to apply search option of "full name" on top of that report, when I am applying the parameter search then it is giving result but not with hierarchy. can you suggest me how I would get the result with search having hierarchy.
Thanks for sharing this information!
ReplyDelete
ReplyDeleteThrough this post, I know that your good knowledge in playing with all the pieces was very helpful. I notify that this is the first place where I find issues I've been searching for. You have a clever yet attractive way of writing on Msbi online training
Msbi online training Hyderabad
Msbi online training India
Msbi online course
Data Science online courses
ReplyDeletelinux online courses
etl testing online courses
web methods online courses
business analyst online course
oracle adf online course
oracle rac online course
msbi online course