0

I need to switch between 2 queries in SSRS Reporting Services, from same report. Queries have same column data, differences are only in group by clauses. I have created a boolean parameter which should decide what query should be executed, but I can't get in to work in Dataset Query designer. Can somebody explain what I should do to make It work?

How I did so far (in Dataset Query designer):

if @chooseSelect = 1
SELECT FROM....
group by...
else
SELECT FROM... 

This returns me errors "Query execution failed for Dataset" & "Invalid SQL statement"

Lucy82
  • 654
  • 2
  • 12
  • 32
  • 1
    I had this a while ago and used the following. which worked a treat. https://stackoverflow.com/questions/8857090/group-by-using-parameters-in-sql – JonTout Jul 31 '18 at 11:39
  • Use management studio to debug each SQL statement – niktrs Jul 31 '18 at 11:46
  • @JonTout, thanks for that, but I allready solved in another way. nice to know though, but my problem with doing like that was also that in group by query I sum one column, and not in other query. So I had to do It like in my answer. – Lucy82 Jul 31 '18 at 12:28

2 Answers2

0

Solved. I used this trick like in this thread:

Only thing I changed is that I don't show column which fetches data from different query (column year in thread example) in my report. Works like a charm :)

Lucy82
  • 654
  • 2
  • 12
  • 32
0

See here: https://stackoverflow.com/a/45369680/3374391

See the note there: DummySP created should be same like SP1 Do the same for Dataset 2..and this works.

Haim Tabak
  • 185
  • 1
  • 11