Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

How to write IF condition in SSRS Dataset?

$
0
0

Hi,

I would like to write a SQL SELECT statement based on the user input parameter.  i.e.  I will have a query list box for user to choose which year to query the data.  If the user does not select any year from the list box, I will run the SELECT query without filtering.  Let's say the parameter is Year.  If the user did not select any year listed in the list box, I will perform SELECT A, B, C FROM TABLE.  If the user select 2016 from the list box, I will perform SELECT A, B, C WHERE C = '2016'.  

How can I write a dataset query in SSRS to perform conditional SELECT statement?  I was trying to use below but it does not work:

=IIF (Parameters!Year.Value=0, SELECT A, B, C FROM TABLE, SELECT A, B, C FROM TABLE WHERE C = @Year)

Any suggestion?

Thanks,


Brian


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>