'Setting a list of several values to one SSRS parameter in "Available values"

I have an (integer) multi-value parameter in my SSRS report. The "Available Values" for this parameter are currently gotten from a query returning an integer from 1 to 15. Everything is working fine when selecting one or several values. Now, I would like to set by myself these a Available Values (and not anymore via a query) and group the several possible values in 3 groups : 1,2,3,4,5 and 6,7,8,9,10, and 11,12,13,14,15. What should be the syntax in the Value field (in the "Available Values")
Report Parameters Properties



Solution 1:[1]

I would suggest you create a permanent table to support this, handy if you need to use it from other projects. You could just add this as a report specific dataset but that seems like more work than it's worth.

CREATE TABLE RangeNumbers(RangeID int, Range varchar(20), iValue int)
INSERT INTO RangeNumbers VALUES 
(1, 'From 1 to 5', 1),
(1, 'From 1 to 5', 2),
(1, 'From 1 to 5', 3),
(1, 'From 1 to 5', 4),
(1, 'From 1 to 5', 5),
(2, 'From 6 to 10', 6),
(2, 'From 6 to 10', 7),
(2, 'From 6 to 10', 8),
(2, 'From 6 to 10', 9),
(2, 'From 6 to 10', 10),
(3, 'From 11 to 15', 11),
(3, 'From 11 to 15', 12),
(3, 'From 11 to 15', 13),
(3, 'From 11 to 15', 14),
(3, 'From 11 to 15', 15)

Of course you could normalise this more but I left it like this for the sake of simplicity.

Once you have this, you can create a dataset for your parameter values like this

SELECT DISTINCT RangeID, Range FROM RangeNumbers ORDER BY RangeID

I've ordered this so they appear in your report in a logical order Let's assume this parameter is called @ranges and set the Value to RangeID and the Label to Range

Next create a hidden parameter, lets call this @selectedNumbers

Now create a new dataset using something like

SELECT iValue FROM RangeNumbers WHERE RangeID IN(@ranges)

This will then get populated with all the iValues from the range table matching the selection the users made.

Finally in your main dataset you can just do

SELECT * FROM myTable WHERE fieldName IN(@selectedNumbers)

That should be it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alan Schofield