Filters Multiple values directly on report - reporting-services

I wanted to instead of defining the parameter in the query but use the filter to work as parameters.
I have configured SSRS filter expression like
The parameter is called "Locations" and i am allowing multiple values
From the datasets: The field is called Location
Filter from the dataset
Expression:[LOCATION]
Operator: IN (i tried Like)
Value =Parameters!Location.Value(0)
When i run, it works when i pick one item from my drop down option. But when i pick more than 1 location i get values of the first value picked from the drop down only. It doesn't recognize the multiple choice.

You have enabled the multiple parameter, so you could use expression like below to see whether it works or not(it will recognize all parameters)
Expression:[LOCATION]
Operator: IN
Value =Parameters!Location.Value
Zoe

Related

Pass a Parameter in SSRS while removing Dashes

I am passing a unique ID as parameter in SSRS report. In the source table, unique id does not contain dashed. However, the user may insert Unique ID including dashes "-" and in some cases without dashes. Is there a way that we could remove dashes from the parameter.
For example, unique id 3120-20268-8 is stored in table as 3120202688. How I could retrieve if user pass multiple values with or without dashes in the SSRS Report.
When is used below query, it gives record against single value only. However, gives error when more than one values are provided.
select * from Table
where Unique_ID in (REPLACE(#Unique_ID,'-',''))
For more than 1 values, it gives errors mentioned below:
The replace function requires 3 argument(s).
Query execution failed for dataset 'ATL_List'.
Thanks
One of the simplest mechanisms for this is to create an expression based parameter to hold the sanitised input. This parameter would be hidden so the user is not aware of it, but the rest of the usage of the parameter is the same.
NOTE: You could do something similar with a query based default value, but this case is easier to do via a simple expression
Single Value Parameter
Create a new parameter:
set it to hidden
Set the default value expression:
=Str(Parameters!inputID.Value).Replace("-","")
Multi-Value Parameter
This is only slightly trickier, in the expression we can join the selected values together into a CSV string, then process that value and then split it back:
Set the parameter to multi-value, but still hidden:
Set the default value expression:
=Join(Parameters!inputID.Value,",").Replace("-","").Split(",")
Without going to detailed, if we made the sanitised parameter temporarily visible, just to demonstrate the conversion, it should look like this:
The parameter MUST be hidden!
NOTE: DO NOT make your sanitised parameter visible as in the above screenshot in your deployed report! Doing so will mean that it will not pickup changes made to the input value after it has rendered the first time.
remember that we have exploited the default value, we haven't arbitrarily defined en expression to always execute.
The output when the parameter is hidden is calculated when the report is rendered, it's just harder to visualise the behavior in this static post:
In your DataSet query you would just use the sanitised parameter:
SELECT * FROM Table WHERE Unique_ID IN (#sanitisedMultiValue)
You should be able to use the replace function in your report to format the parameter value after it has been entered, something like the below
replace(Fields!Paramater.Value,"-","")=FieldinYourTable

Using a parameter as a filter - Multiple values not working

The report works for just 1 choice, but when I add more than one, it does not return anything ( no errors, just nothing in the report).
My SQL statement includes the parameter #Region
where Region_Name IN (#Region)
In the Region parameter's properties, I set to allow multiple values.
in the dataset filter's properties:
Expression: =Fields!Region.Value
Operator: IN
Value: =Parameters!Region.Value(0)
*EDIT
I removed the dataset filter as suggested.
Below are the properties for the parameter.
The available values come from another data set that is a distinct list of regions.
Your edit makes a lot more sense. To use multivalue parameters you just need to reference the parameter in the usual way, except use in within the SQL:
select cols
from table
where specificcol in #Region
And then don't have a dataset filter set, just make sure there is a reference to the Region parameter in the Parameters property page. The filtering of the data is handled by the inclusion of the parameter in the SQL, so you don't need to also have a filter on the SSRS dataset.
Instead of using a parameter to go back and forth between the stored procedure and the report, I created the parameter and used it in the tablix properties.
Expression: =Fields!Region.Value
Operator: IN
Value: =Parameters!Region.Value
When you first create the value, it adds a (0) to the end of the expression. Remove that and it works as expected.
Thank you #iamdave for the help!
EDIT:
I came back to this and was able to filter using the parameter and stored procedure.
I followed a link from a question to here: http://www.codeulike.com/2012/03/ssrs-multi-value-parameters-with-less.html
I created a dataset parameter and removed the one from the tablix properties. Then created the function provided and it worked. I did not mess with the "ALL" features in the post.
Thanks for all the tips. Brent

Filter Multivalue Parameter on Dataset

So I have a multiple value parameter than contains 3 options. >250K, <250K, >2M.
I also have a table that consists of multiple columns.
. Because the parameter is a multivalue, i am having difficulties filtering the dataset.
I need to filter the dataset by checking, (if > 250K is selected, filter the dataset accordingly), (if < 250K is selected, filter the dataset accordingly) and (if > 2M is selected, filter the dataset accordingly).
I was told to use a join and split on the parameter within the (>250K condition, then do a contains to see if it contains any of the parameter values) but I am not as advanced in my knowledge of coding to be able to do that.
Any Suggestion? Thanks in Advance
I previously tried the method below but then i came to realise that it wont work because the parameter is a multi value.
I know its been a while since you raised this, you were on the right track but all you should need to do is add a filter to the Tablix on the field you will be filtering, use the 'in' operator and in the Value type [#Yourparametername] the square brackets and case sensitivity are important. Also ensure the expression type is correct, in your case it looks like you are using Integer. The image should help.
If you want to use multi-parameters, In the dataset, you can read parameter value using JOIN.
Example:
If you want to read multiple values for #MyParamter in a dataset given in the following example:
Dataset Parameters
you need to use =JOIN(Parameters!myMultiParamter.Value,",") as an expression to read all selected values in CSV form.
Expression
Now the #ParameterValues param has all selected values as comma separated values and you can use them in your dataset code as per design requirements.
Note: It's not necessary to use a comma but u can use anything you want to separate values.
Your sql query where should look like
Where
(
(0 IN (#Parameter) AND ValueColumn<250000)
OR
(1 IN (#Parameter) AND ValueColumn>=250000)
OR
(2 IN (#Parameter) AND ValueColumn>=2000000)
)
One parameter
Two parameters
All parameters
Once you return the value you can also use charindex or patindex* and look for where the value in your where clause is a pattern where the index number is > 0 . For instance if the returned string from SSRS is '01,02,03' and then your where clause has something like this right(field, 2) which would result in value '03'. you change your where clause to be where patindex('%' + right(field, 2) + '%', #returnedstring) > 0 which will give you results. The keeps you from having to parse apart the #returnedstring parameter in your sql code.

How to apply multiparameter to ssrs report filter

I have a master that can be filtered using 4 different parameters. I used a iif statement to join all the parameters to filter the report.
The problem I am now having is when more than one paramater is selected, it tends to return values for the first parameter rather than for all
My paramter expression is as follows:
expression
iif(IsNothing(Parameters!Div.Value)=0,Parameters!Div.Value
,iif(isnothing(Parameters!St.Value)=0,Parameters!St.Value
,iif(isnothing(Parameters!Sp.Value)=0,Parameters!Sp.Value
,Parameters!Hc.Value)))
values
=iif(IsNothing(Parameters!Div.Value)=0,Parameters!Div.Value
,iif(isnothing(Parameters!St.Value)=0,Parameters!St.Value
,iif(isnothing(Parameters!Sp.Value)=0,Parameters!Sp.Value
,Parameters!Hc.Value)))
Any help will be helpful
I think what you are trying to do is something like this:
=IIF(NOT ISNOTHING(Parameters!Div.Value), Parameters!Div.Value,
IIF(NOT ISNOTHING(Parameters!St.Value), Parameters!St.Value,
IIF(NOT ISNOTHING(Parameters!Sp.Value), Parameters!Sp.Value,
Parameters!Hc.Value)))
Do you only want to check for one value?
I usually check each parameter separately so it uses all of them at once. Though there may be a situation where your theory is what you want.
If you want to evaluate all the parameters, just add them to the FILTER of the dataset, table, or group. Choose your field in the Expression and the Parameter in the Value.

Using a list parameter in SSRS

I need to be able to set an SSRS parameter to contain multiple values.
In TSQL, I can have a where clause that states:
where Attribute in ('Value1', 'Value', 'Value3')
What I need is in SSRS to have:
where Attribute in (#Attribute)
Where I am getting hung up is how to format the parameter value expression so that SQL sees it as: 'Value1', 'Value', 'Value3'
I have had some luck making the where clause look at only the first value, but I need it to look at all 3. How would I format the expression to do that?
I would just allow it to accept multiple values, and check each value individually, but I need the drop down list to have groups. So, if the user selects GroupA, the where clause uses: IN ('Value1', Value2') and if the user selects GroupB, the where clause uses a different list for the IN.
Hopefully it's just a matter of formatting the expression correctly.
Well, if you didn't have the requirements about groups, this wouldn't be an issue since all you need is to make your parameter a multi-valued one, and on your dataset query do WHERE Attribute in (#Attribute). But taking that requirement into account, the only way I can think of, is to have two multi-valued parameters: #Group and #Attribute. You'll need to make #Attribute not visible and create a dataset to populate it. That dataset would be something like this:
SELECT Attribute
FROM Attributes
WHERE Group IN (#Group)
And create another dataset for your report data:
SELECT <all your data>
FROM YourTable
WHERE Attribute IN (#Attribute)