Say you want to use a parameter in your report with, for example, the names of the countries where you have customers. You will often want a choice in your parameter box that says ‘Show All’, in this case all countries. The solution is as follows. Create a dataset in your report

SQL
SELECT ' _Toon Alles' AS LandNaam,
9999999 AS LandID
UNION ALL
SELECT DISTINCT
LandNaam,
LandID
FROM DimLand AS DL
ORDER BY LandNaam

rapport_parameter_show_all_1
We now have a list with all unique countries from our country table. As the first country we have the country ’ _Toon Alles’. It will act as the parameter that shows all countries. Note the space at the start. It makes sure this one ends up at the top.

**
Create the parameter
**Go to your report parameters and create the following parameter:
rapport_parameter_show_all_2

Dataset for use in the data region of your report
Finally, the dataset that feeds the report needs something extra in the WHERE clause, so that all places are shown when ’ _Toon Alles’ is chosen!

SQL
SELECT *
FROM DimKracht
WHERE(@GeselecteerdeLandID = 9999999 OR LandID = @GeselecteerdeLandID)

By default the parameter has the value 9999999. This is ‘Show all’. This is what we do above in our main dataset: check if the parameter is 9999999. If it is, it stops and shows everything. If it is not equal to 9999999, it automatically goes to the OR part and checks the parameter that was entered.

rapport_parameter_show_all_3

Frequently asked questions

How do I create a 'Show All' option in an SSRS parameter?

Create a dataset with an extra row ' _Toon Alles' and ID 9999999, with UNION ALL above the real values. Use that dataset for the parameter.

Why is there a space before ' _Toon Alles' in the dataset?

The space makes sure the option is at the top of the list in the parameter box after sorting.

How do I change the WHERE clause for the Show All option in SSRS?

Use WHERE (@GeselecteerdeLandID = 9999999 OR LandID = @GeselecteerdeLandID). With 9999999 the query shows all rows. Otherwise it filters on the chosen country.

Which value does the SSRS parameter use for Show All?

The value 9999999. This is also the default of the parameter, so the report shows all countries by default.

How does the OR in the WHERE clause of the Show All parameter work?

The query first checks if the parameter is 9999999. If so, it shows everything. If not, it goes to the OR part and compares LandID with the chosen value.

Comments

Your email address is not shown. A photo comes from Gravatar, if you have one.