I’m looking for a way to add a value to a parameter whose available values are retrieved from a simple query. I just started messing with SSRS today, I hope I’m not doing it all wrong.
Executing the following procedure from the report project (messy, I know):
CREATE PROCEDURE RAW_TIME_VAR
@EMPLID as varchar(6) = NULL
, @EMPLNAME as varchar(80) = NULL
, @CHARGENO as int = NULL
, @TYPE as varchar(8) = NULL
, @STARTDATE as date = NULL
, @ENDDATE as date = NULL
AS
Select * from DBO.RAW_TIME
Where ([EMPL ID] = @EMPLID OR @EMPLID IS NULL)
AND ([EMPL NAME] = @EMPLNAME OR @EMPLNAME IS NULL)
AND ([CHARGE NO] = @CHARGENO OR @CHARGENO IS NULL)
AND ([CHARGE TYPE] = @TYPE OR @TYPE IS NULL)
AND [CHARGE DATE] Between @STARTDATE AND @ENDDATE
There are two datasets in the Report Project (I’m using VS2008 Business Intelligence Development Studio). One generated from the procedure above (RAW_TIME_DATASET), and the other a query from the same view to populate employee ID’s and names (NAMES):
SELECT DISTINCT [EMPL ID], [EMPL NAME]
FROM RAW_TIME
ORDER BY [EMPL ID]
I want to be able to populate the @EMPLNAME parameter with all employee names from the NAMES dataset while also being able to pass NULL by selecting value “All” in the parameter combobox. “All” can be passed by the query by using UNION, which places it in the combobox without it being in the View, but I cannot then pass it through the report as NULL. Errr… I hope this makes sense.
you are on the right track.
If you check the report_data tab, you will see a parameters folder. Expand it and you should see all the parameter from your initial query. Right click the EMPLNAME parameter, select parameters properties, go to available values and do the following configuration:
also, on the general tab, mark the parameter to accept null values
now, the trick is on the NAMES dataset. You have to select all the names, plus a row with a null value. There are a few ways of acomplish it, the easiest is add something like this to your query:
If you don’t, the report will complain that the parameter cannot be null.
result (I only added 2 parameters for simplicity):