2

I need to write a SSRS report which pulls data from a datasource multiple times.

One time the flag will be set to 0 and the next time 1. There needs to be a data row which groups by a couple of columns. So far, not a big deal.

The tricky part is that the first query from the datasource has a summary line as does the second query to the same datasource. And then there needs to be a grand total of both at the end, after the results of and totals of the previous queries.

Not sure if I'm expressing myself clearly, but if anyone could help me figure out how to tackle this I would be appreciative.

Currently, I'm thinking about hitting the dataset three times with three different tables accessing it. The first time the flag is sent as a parameter with the value of 0, the second time as 1, and the third time with a null value and it gets back all the results.

This will also prevent me from having to sum up across two tables, which I don't really know how to do either. But that's for a different thread if that's the right solution.

Thanks in advance.

1 Answer 1

0

You may get mileage from changing the data source to do the work for you. i.e. a sql procedure something like

select col1, col2, col3 into #Result

select 1 as colIndicator, col1, col2, col3 where col3='a value'
union
select 2 as colIndicator, col1, col2, sum(col3) where col3='a value'
union
select 4 as colIndicator, col1, col2, col3 where col3='a differnt value'
union
select 5 as colIndicator, col1, col2, sum(col3) where col3='a differnt value'
union
select 6 as colIndicator, col1, col2, sum(col3)

you can then filter the dataset for your display and order by colIndicator, col1, col2 as required.

2
  • The only problem about this solution is that I have to have a summary row after the first part and then again after the second part. And then there is also a summary line for the overall section. Nov 30, 2010 at 5:24
  • My bad, I thought this is what you were after.
    – Nat
    Nov 30, 2010 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.