SSRS: Master-detail report with two datasources

Svish picture Svish · Apr 28, 2009 · Viewed 11.5k times · Source

I have two local data sources that I can push into the report. Works no problem. But how do I set up the report? One data source contains a list of employees, and info about them. The other contains a bunch of working hours for each employee.

I would like to use a table for the list of employees, and then have another table for the working hours beneath each employee (with their working hours).

Is this even possible? Do I have to use a Sub-Report? Would I have to merge them into one datasource? =/

Answer

AaronSieb picture AaronSieb · May 1, 2009

As far as I can tell, it is impossible to nest one dataset inside of another one without using a subreport.

This means you need to do one of two things:

  1. Refactor your two datasources into a single datasource. For example, perform a join between the employees and the working hours for each employee. You can then use the grouping properties of the Table object to format the list the way you want it.

  2. If joining the two data sources is not practical, you can use subreports to accomplish what you want. Create a subreport containing the working hours data source and give it a parameter for the current employee. Filter the working hours by this parameter.

    In your parent report, you can place the subreport in the list, and pass the employee ID for the current row as a parameter.

    Note that there are a few formatting quirks involved with using subreports. I've been able to work around them in most cases, but the preferred method would definitely be number one above.