How can we create a Master Detail or Summary Detail report in SSRS 2008?
- Add a New Report in the report solution & name it as “
- Create a data source.
- Create 2 datasets as “
dsMaster” & “
- To create these 2 datasets, find some master detail table, e.g.,
AccountType ? Master Table & Accounts ? Detail table.
- First create the query for Master as below,
SELECT ID, AccountType, Description FROM AccountType
- Then create the query for
SELECT AccountID, DateCreated, Income, Expenditure FROM Accounts
WHERE AccountType = @AccountType.
- Once we do this,
@AccountType parameter will be added in our parameter list as shown in the figure below:
- Right click on the “
- On the General Tab of this parameter, go to the “Select parameter visibility” & select “Hidden” from the list. (This step is done so that when we view our report, this parameter won’t be visible in the parameter list. The value for this parameter is handled internally which is the next step to be done.)
- Now go to the “Default Values” Tab & select “Specify values”
- Click on the Add button, a dropdown will be visible.
- Now click on the “
fx” button & write the below expression for the default value for the parameter.
- Now click on “Ok”, this will set our parameter. (This step will assign a default value to our parameter. If you fail to do this step, an error will be raised as parameter is not assigned any value.)
- Now on the Design areas, add 2 tables, one for Master & other for Details.
- Select the
dataset as “
dsMaster” for the first table, this table will show our
- Select the
dataset as “
dsDetails” for the second table, this table will show our
- Now on the
Master table, click on the column detail where you want to do a drill through.
- In our example, I have selected this for “
- Right Click on the Description textbox, go to the “Text Box Properties”.
- On the “Text Box Properties”, go to the “Action” tab.
- On the “Action” tab, select “Go to report” hyperlink, after this go to “Specify a report” section, there select the Current report on which we are working (in our e.g., it is “
- Now map all parameters which are required to load this report, add it using the “Add” button.
- In our case, we have only 1 parameter as “
AccountTypeID”, select it from the drop down list.
- For the value for this parameter, select the ID from the drop down list, this is from the 1st
dataset, i.e. “
dsMaster”. Please refer to the below figure for the settings:
- Now click on Ok.
- Now go to the “Font” tab & in the Effect area select “Underline”, this will help the user to identify that there is a link on this cell.
- Once this is done, the next step is to handle the visibility of the “
- This can be done as follows, 1st map the “
Details” table with the “
dsDetail” data set.
- Now right click & select the “Tablix properties”.
- Go to the “Visibility” tab of the “Tablix properties”.
- Here go to the “When the report is initially run” section & select “Show or hide based on an expression.
- Once you select this, a text box will become visible. Now click on the “
fx” button & write the following expression:
=IIF(Parameters!AccountTypeID.Value <> -1, False, True)
- This expression helps us to control the visibility of the 2nd table i.e. “
- Please note: When you are handling the visibility of the 2nd table, make sure the parameter which you are selecting for controlling the visibility should have a value which is not there in our DB.
- Now click on the “Ok” button.
- Now preview the report, it will only show the “
Master” table first. But when you click on the “
Description” cell, the “
Details” table will become visible.
- In this way, we can implement the “Master Details” report in SSRS 2008.