how to capture grater than symbol parameter to build date field comparison in where clause for SSRS parameter report

Viewed 25

new to SSRS report design. Although, I've used CASE statement before but not sure how to utilize in a condition where SSRS report needs to two parameters ( parameter symbol (>,<,=,%) and parameter date ) pull data from a dataset.

I'm wondering if CASE statement can be used to achieve this need? Or any other suggestion that would work for this condition, will be greatly appreciated.

PS: I've not come across such example so far

1 Answers

I'm assuming that you want to parameterise the actual operator so the user can for example, choose < 1000 or > 50 etc...

If that's correct then you can do this as follows.

Assume we have two parameters

pOperator which has values of ">", "<" and "=" (note for the = option you will need to specify this as an expression ="=" or SSRS will think you have a blank expression.

pMyValue which will allow the users to type a number in

What you need to do is change the dataset query to be an expression, so something like this.

="SELECT Employee, Salary FROM myTable
     WHERE Salary " & Parameters!pOperator.Value & " " & Parameters!pMyValue.Value

If you had used > and 30000 as your parameter values then this would return

SELECT Employee, Salary FROM myTable
     WHERE Salary > 1000

You could also have a single parameter where the user can type the whole ">=15000" and then just replace the two parameters above with a single one.

Related