Create a dataset which is a subset of another dataset in SSRS

Viewed 8202

In my SSRS report, I already have a dataset A(by running a SQL script), and parameter P1 use all the records in A. Now I want to get a subset of A, and use another parameter P2 to refer to it.

Is it possible that get the whole and the subset of the dataset at the sametime and only run the script once?

I guess creating a shared dataset is a possible way, but the dataset A is just for locally use and shouldn't be shared.

2 Answers

One way I've achieved this is with grouping. If Dataset A already has all the stuff you want, you can group that dataset with criterion P2 = TRUE. This splits Dataset A into two groups -- one where P2 condition is true, and the other where P2 condition is false.

For instance consider a dataset with two columns, Label and Amount. I want to subset my data where Label = "LabelNameOne". I create a group around my dataset with expression =Fields!Label.Value = "LabelNameOne", which then automatically creates a subset for me. Assuming you wanted it to filter on a user-chosen parameter at run time, you just sub in that parameter in your grouping expression: =Fields!Label.Value = Parameters!P2.Value.

Related