I have one input parameter and two multivalued parameters. I will set the two multivalued parameters as optional. Is there any way to get the results from input in the report without selecting the two multivalued parameters? I tried this one, but it doesn't work: Link
1 Answers
So with countries in mind, ill try to do a quick example. I realize this isnt a multivalued param solution, but it does what you need. In the RDL you will define two parameters, one for Country, and another for City or whatever. You could then populate the country parameter from a stored procedure, and use the Name as the display text, and the ID as the value. (If you set the default value to null, All will be the first item selected)
SELECT C.Name, C.ID From Countries AS C
UNION
SELECT 'All', NULL
Then, you populate the City parameters values with another procedure which uses the selected value for the country parameter (This creates a forward dependency, so make sure that Country appears before City in the parameters list or you will get an error when building the report).
DECLARE @Country_ID int
SELECT C.Name, C.ID FROM Cities AS C
WHERE (C.Country_ID = @Country_ID)
UNION
SELECT 'All', NULL
Now you have your procedure which returns the result set for the report accept both a Company, and a City ID parameter and in your where clause you will have something like this:
DECLARE @Country Int,
@City Int
SELECT * FROM X
WHERE (X.Country_ID = @Country_ID OR @Country_ID IS NULL) AND
(X.City_ID = @City_ID OR @City IS NULL)
Obviously you will have to change this a bit to fit your query, but this should allow the user to pick just a country, or a country and a city, or none at all.
PS. Dont forget to check the "Allow Null Value" checkbox for the paremeters in question if you plan on using null as your sentinel value.