Multi Parameter in SSRS

Experts -

I have a SQL table, "OUT_Table" which has around 50k rows. There are few columns (Region, Sub-Region, Country, Channel etc) which are a part of the table which i am using in SSRS as parameter.

Now, the client wants me to make the parameter, multi.

and they also want, "All" and "None" on each parameter.

for All, "Select Distinct Region from OUT_Table" will give me all data, however how do i do that in multi level?
ManjuIT - Project ManagerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Koen Van WielinkBusiness Intelligence SpecialistCommented:
Assuming that you are working with stored procedures, to handle a multi-select parameter you need a split function that splits the comma separated values of the single string into multiple values. The function for this is given in this question as well as how to use it:

In order to handle the "All" parameter value, the easiest way is probably to add it as a selection in your parameter list. You can do this with a simple union query that adds "All" to your parameter values:

Select 'All'

union all

select distinct region
from OUT_Table
order by region

Open in new window

You then need to adjust the where clause slightly to cover for the "All" option:

where	(Region in (Select val from dbo.fn_split(@region)) OR Select val from dbo.fn_split(@region) = 'All') 

Open in new window

This would either return only the records for the selected regions, or All regions if the value of the parameter is "All".
For the None parameter, we need a bit more information. I assume that this pertains to records where the Region column is not filled with a valid Region value. That means it's either filled with a NULL, a Blank, or a dummy value that indicates no region is filled. The best way to cover this is to allow "Null" to be selected as the parameter value in the parameter configuration in SSRS. In that case, if the parameter value is Null, you can catch it in a similar way as above with All, but exactly how depends on what value should be used for a None region. If the region column contains a Null, you don't have to change anything, as in that case the where clause will evaluate as "Where Region in (NULL)" which works ok.
But if the Region column is an empty string, you have to use ISNULL() to capture the Null value and use an empty string instead:

where	(Region in (Select ISNULL(val,'') from dbo.fn_split(@region)) OR Select val from dbo.fn_split(@region) = 'All') 

Open in new window

This way if the parameter value is NULL, an empty string is used instead.

I hope this answers your question. I'm making a few assumptions on your data here, but it probably should get you going. Let me know if you have further questions (Timezone here is GMT +7, so might not be able to answer again until tomorrow morning).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.