How to apply parent group for multiple datasets in SSRS VS2008

怎甘沉沦 提交于 2019-12-14 01:28:58

问题


I have been battling this issue for days without success. I have a very tricky format of a report i need to achieve but the main thing is that all the datasets will need to be grouped by 1 parent. I'll attempt to explain...

Say we have dataset1, dataset2. Both have AccountNumber as common field(parent).

I need both datasets to be used in the format/layout of the report but grouped together by AccountNumber, something like this.

[Report Header Data]

[AccountNumber Group]

Dataset1
Dataset2

[end AccountNumber Group]

What is the best way to achieve this? The format of the report has been a major road block on grouping thus making me split the data into multiple datasets, group all them together by accountnumber and then create a custom format per dataset in the report. The flow of the report may be something like this

[Report Header Data]

[AccountNumber Group]
[tablix1]
Dataset1
[tablix1]

[tablix2]
Dataset2
[tablix2]

[end AccountNumber Group]

Looking forward to the discussion on this!


回答1:


There are multiple ways to achieve this effect, and the best for your situation depends on the details of your report. So I'll just give some of the techniques I've used in the past:

  1. Join the two datasets into one

    Joining the datasets into one in your query is one of the simplest answers, and works across all versions of SSRS. It can make the SQL queries large, but it makes report layout simple.

  2. Use the Lookup(...) function

    SSRS 2008R2 added the Lookup(...) function, which can be used to access items in a second dataset. It's a little bit awkward to use, and requires a separate formula for every field to be accessed, but it is very powerful for retrieving a few fields from a different dataset.

  3. Sub reports

    Similar to the approach descibed in the original question, This lets you create a parent project with one tablix, and then place a subreport within. The subreport will be called multiple times, with the Grouping item as a parameter. Each run of the report should only return the report for that instance of the group. This can be very powerful, but maintenance is difficult: you have two places to change some thingss, and it can require manual tweaking to make sure columns line up correctly. The subreport will often be the fastest report to run, since it is getting called many times.

[NB: StackOverflow.com isn't the best place for discussions. The design of the site is set up to avoid discussion and aim towards question & answers, not discussion.]




回答2:


I don't know if there's a perfect solution here.

Based on your description, (and it sounds like you're leaning in this direction already) you'll need a Dataset for each distinct AccountNumber, and create a new list or table based on this.

Once you have this set up you need to embed the different Dataset objects (i.e. tablix1, tablix2) in each row.

The main issue here is that you can't use multiple Datasets when embedding tablixes within tablixes, so this makes me think that you may need a subreport solution - this way the subreports can take an AccountNumber parameter and each use a different Dataset.

So something like:

[Report Header Data]

[AccountNumber Group]
[subreport1]
[tablix1]
Dataset1
[tablix1]
[subreport1]

[subreport2]
[tablix2]
Dataset2
[tablix2]
[subreport2]

[end AccountNumber Group]

This will repeat for each AccountNumber as required.

It's tough to say without knowing exactly what your data looks like, but in 2008R2 and above you can use Lookup and LookupSet to join Datasets, but that will be cumbersome for multiple values, even if you are running the correct edition.

Again, depending on your data, another option is adjacent groups, if you can manage to get the data in one Dataset... This would allow to have different groupings next to another under the AccountName group, but it's a long shot.




回答3:


It would be great if we know the report data e.g Payslip, payslip with loan balance (ie Dataset 1 for payslip and Dataset 2 for loan).

Anyway, the format will depend on the required output of the report. i.e If your planning on produce calculation like sum in the report and if the result output will be per Dataset or for both dataset.

Assuming you will need sum calculations, if the calculation result will be per dataset, then option 2 is good, if the calculation result is for total (Dataset 1 + Dataset 2) then option 1 is better.

If no calculations or total result is required, either will do.



来源:https://stackoverflow.com/questions/18598711/how-to-apply-parent-group-for-multiple-datasets-in-ssrs-vs2008

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!