Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Default value for parameter in SSRS 2012 Expand / Collapse
Author
Message
Posted Monday, June 9, 2014 2:27 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Yesterday @ 8:04 AM
Points: 41, Visits: 166
I have a report dataset reading from a database table (OLTP), I'm able to set the default to 'Select All' but this displays all the values separated by a coma, how do I set this just display 'All'
Post #1578724
Posted Tuesday, June 10, 2014 7:13 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, July 21, 2014 2:46 AM
Points: 11, Visits: 35
If I understand this correctly, you want to show all the rows from your table, plus an option showing literally the word "ALL"?

This is quite easy as long (as you don't want a multiple select parameter) - you just need to have a query like this as the source of your parameter values:

SELECT description, ID FROM ParamTable 
UNION ALL
SELECT 'ALL' description, 0 ID
ORDER BY ID

(Assuming that you don't have a zero ID in your table, otherwise use any value for ID that you're sure won't appear in the table).

But then you have to code for the ZERO that you'll be passing from your report to your underlying SQL code,

So you might have something like :

SELECT colA, colB, colC FROM YourTable WHERE colD = @YourSSRSParm

and if you want to return all the rows with no filter if you've chosen the 'ALL' parameter with a zero value, you'd need to change it something like:

SELECT colA, colB, colC FROM YourTable WHERE CASE WHEN @YourSSRSParam = 0 THEN 0 ELSE colD END = @YourSSRSParm

If you DO want to have a multiple select parameter - then SSRS will pass back a string of comma separated values and you'll have to code for that in your stored procedure, converting that string to a table then right joining it to it or using IN - there are many publicly available examples - using a table function is quite easy.
Post #1579172
Posted Tuesday, June 10, 2014 8:13 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Yesterday @ 8:04 AM
Points: 41, Visits: 166
Thanks for the reply, will test this and let you know. My concern with thIs is it seems as if it will retrieve all the values in the table making my parameter dropdown list very long. Is there a way that we could use distinct?
Post #1579230
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse