comparison expressions in SSRS parameter

  • I have created a report with a parameter that passed "qty on hand" The end users would like to be able to enter comparison operators in the parameter text box at run time ie:

    >X, >=X =X etc..

    Is this possible and if so, how should I accomplish setting this up?

    Thanks

  • I have never seen that capability. You would have to come up with some way to create dynamic SQL, but not sure if that can be done.

    Also, sounds risky. This sounds like another opening for SQL injection.

  • you will need 2 parameters like

    @operator and add none query values for the the operator drop down

    1. >; 2. <.......etc

    then create another parameter for quantity ex. @qty this too is a non-queried value (you may add a query to limit the max quantity but it depends on what the user wants). then simply write a query for the main dataset like so

    ="select itemid, itemname, qty from itemmaster " &

    " where qty " & Parameters!operator.label & space(1) & Parameters!qty.value

    this is the easiest way of doing it, can be further tweaked depending on your needs

  • I have had to do similar things in the past and you may want to get away from allowing text entry and think about a dropdown list or some similar control that forces the user to select from a predetermined list of options. Then you can write a stored procedure that handles that input in a case statement. This has an added bonus of preventing sql injections.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply