One can put the distinct values from a table into a dropdown in SSRS reports using
'parameter' --> "Parameter Properties' --> 'Available Values' --> Get Values From a query.
This works. However, is there a way to add a blank so that one can filter for any / all with a 'like' statement.
I use Visual Studio 2015, but the underlying databse is SSMS 2008 R2 (!)
The SSRS syntax for this filtering is VB:
="*" + Parameters!OurParameter.Value + "*"
It would be nice to let the user see all potential rows, if that is what the user wants.
There are a couple ways you can go about letting the user select all the values.
One option is to set "allow multiple values" in the parameter properties. This adds a "Select all" option to the drop down list. In order for this to work, you'll need to update your query to accept multiple values.
For example, instead of
MyCol = :MyParam
You would write
MyCol in (:MyParam)
The other option is to UNION an "All" option to the query that you are using to populate the available values. In order for this to work you would update the filter in your main query to something like this:
(MyCol = :MyParam OR :MyParam = 'All')
Related
I'm trying to set the parameter as "All" when the user clicks on "Select All" option in the multi-select parameter. The requirement is to not show all the selected values in the top.
Currently, I'm getting this:
This is the expected value when all are selected:
How to add this requirement? I have tried with adding dataset with "All" value in the table but that is only useful in case I need to display the value inside the report but I need to show it as the parameter in the place where we are selecting parameters.
You can add the 'All' entry to your parameter by UNIONing it in your parameter dataset (it sounds like you have already done this), and then just interpret that in your dataset query.
So your query might then look like this.
SELECT * FROM myTable
WHERE (Result IN (#myParameter) OR #myParameter = 'All')
How to return everything in Report Server if parameter value is blank or null?
The solution:
SELECT some_column
FROM your_table
WHERE (#y is null or y >= #y)
Doesn't work in SSRS since "Allow null value" cannot be turned on, when parameter "Allow multiple values" is turned on.
Thank you.
There are a couple of ways around this but the simplest is just to use the "Select All" option at appears at the top of multi-value parameter lists. If you need this to be the default then set the default and available value to the same query.
The "Select All" option is shown automatically for multi-value parameters when there is more than a single value in the list as shown here..
Other ways are similar, for instance you can add a value to the top of your parameter's available values list that has a label called "All" or something like that and a value you can look for in your query (e.g. -1).
BTW: Your sample code would not work with a multivalue parameter if used directly in the dataset query you would normally do something like
SELECT some_column
FROM your_table
WHERE (#y =-1 OR y IN(#y))
I'm using SQL Server Reporting Services for SQL 2008 R2. My reports are filtered by two drop-down menus that are populated from a table, one of them displays a build number. I'd like to give users the option to choose "All" and so return data for all build numbers and not just one.
How do I add this option to my drop-down filter and make it work correctly?
Thanks very much for any help provided.
J.
I'm assuming you don't want to use a multi-value parameter here, you only want users to run against all builds or just one, not a selection of builds. Otherwise you'd just use a standard multi-value parameter.
One way to do this is to return an extra row for all builds in your parameter dataset, e.g. something like:
select buildId as null, build = 'All'
union all
select buildId = build, build
from builds
I'm returning two columns here so we can pass a NULL value parameter but still have a user-friendly description to display in the report.
Set this up as your parameter dataset. In the report code you can then use the parameter to do something like:
select *
from builds
where (#build is null or #build = build)
Which will return all builds when #build is null and a specified build if #build is not null.
Would it be correct to simply change the where clause in the stored procedure to
Where [field] LIKE #variable
Then in SSRS under the Available Values have the "ALL" parameter value be % (the percent symbol) ?
Is there an error in logic here. It seems to have the desired result
I want a parameter to load available values from a query (or whatever) and "allow multiple values." When I do so the list begins with "Select All."
That's great, but there appears to be no way to default the parameter to "Select All" which is not acceptable in my case. This particular report will have 8 optional parameters and if htey have to select "Select All" multiple times, this is hardly optional.
Therefore, I create my own "..All" option and the code to accept it. I can default to that, but then the user sees:
(Select All)
..All
This looks unprofessional. I've scoured the net and there doesn't appear to be an answer to this problem.
Is there any way to suppress (Select All) or achieve what I need? Any ideas?
Actually, the answer turned out to be that you have to set your Available Values and Default Values to the same Dataset and field.
If you do that, SSRS automatically selects every option in the list. It's not pretty, but it works.
Coincidentally you have to handle nulls in your dataset query too and replace them with some value such as "None." SSRS parameters will not allow the user to select "Allow multiple values" and "allow null values" at the same time. If your field contains nulls, SSRS will not throw an error but it will not default either.
I'm going to follow up with a blog post on this problem in the near future.
You can also use the Split() function to return multiple values.
For example, if the dataset is a bunch of varchars like
SELECT 'A' UNION SELECT 'B'
The following default value to select all for the multiple value parameter would be:
=Split("A,B",",")
I have a report in SSRS and one of the parameters I use is Cities. The user can select from a list of cities to pull the report for that location, or multiple locations. My datset is simply a select * from tblCities. When I run the report, I do see that one of the options is "Select All." But, I'm wondering - is there a way I can get this "Select All" option as the default value, so that by default all cities are selected?
And, along those lines, but a separate question - is it possible to make this drop-down optional? I have tried the allow NULLS checkbox, but for multi-value parameters, it seems SSRS does not allow this.
FYI - I have only begun using SSRS; know very little about it.
is there a way I can get this "Select All" option as the default value, so that by default all cities are selected?
Yes you can.
Open the Report Parameters dialog: Layout tab, right click anywhere on the canvas that is not the report, select Report Parameters
Select the parameter (cities in this case), from the list on the left
Select the appropriate default setting in the default section, lower righthand corner
One option is where you can statically define a value. IE: =0 or whatever the value is for the Select All option. FYI: I've found that what works in the Visual Studio preview doesn't work when live.
Another option is if the list of cities comes from a stored proc, you order the output of the sproc so Select All is at the top of the list. Then you select the radio button under the static value one (can't remember, not at work to check ATM) - you'll have to select the dataset the sproc is associated with, then the column that the value comes from.
is it possible to make this drop-down optional?
When you say "multi-value", are you actually able to select multiple values from the list? IME, all you get is a drop down & can only select one of the options available.
Allowing null is just an accepted value - the optionality is really handled in the query so that if a sentinel value is provided then the criteria isn't included in the query. IE:
AND (#cities IS NULL OR t.city = #cities)
That's quick & literally dirty. ORs are poor performance.
Make these changes to the specified report parameter:
In order to have all fields selected, make the [dataset] and [valuefield] at "Available values:" equal to the [dataset] and [valuefield] at "Default Values" (assuming you have a query for determing this)
In reports when we want to default the multivalue parameter to 'Select All' following are the steps.
Open the Report parameter window from the Report menu.
Select the Report parameter from the left handside of the window.
Select 'Multi-value' checkbox and appropriate 'Available values'.
Under default values select 'From Query' radio button'.
Select the appropriate 'Dataset'.
Select appropriate 'Value Field'.
Save the Report and select Preview Tab. You will find all the items selected in the multivalue parameter list and the result displayed for all the selected items.
Go to the either the Data tab or the
Layout tab.
From the Report menu, select Report
Parameters
Select the desired parameters, in
this example, cities
In the lower right hand region of the
screen, set the Default values radio
button.
Set the Dataset and Value field drop
down lists to the exact same options
as the DataSet and Value field sections from the Available Values settings above.
This assumes that you are using the "From Query" option under "Available values" If you are using the "Non-queried", see the answer by OMG Ponies.