Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Default value for parameter in SSRS 2012


Default value for parameter in SSRS 2012

Author
Message
thamilanga
thamilanga
SSC Rookie
SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)

Group: General Forum Members
Points: 43 Visits: 229
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'
chris.smith 91049
chris.smith 91049
SSC Rookie
SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)

Group: General Forum Members
Points: 33 Visits: 49
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.
thamilanga
thamilanga
SSC Rookie
SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)

Group: General Forum Members
Points: 43 Visits: 229
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?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search