SSRS Ignore Filters Based on a specific Filter used - reporting-services

Good day
I have a SSRS report that has 4 filters.
One of the 4 filters is a "Search Parameter".
When the user uses the "Search Parameter" (field/filter, types something in), I want to ignore the other three filters despite them having values or not.
I've tried CASE/SWITCH statements in the Expression of the Parameter (DataSet Properties), but no luck.
Does anyone have an idea on how I can get this done

The Filter is quick and convenient but only allows AND relationships between the filter criteria and you want an OR relationship here.
The good news is that you can make more complex filter logic by using expressions. We will create a boolean filter expression that evaluates to whether you want to filter the row or not and compare this to True.
Have only one filter criterion and click the expression editor button. Make the expression something like:
=IIF(IsNothing(Parameters!SearchParameter.Value), Fields!Field1.Value = Parameters!Field1Parameter AND Fields!Field2.Value = Parameters!Field2Parameter AND Fields!Field3.Value = Parameters!Field3Parameter, Fields!SearchField.Value LIKE "*" & Parameters!SearchParameter.Value & "*")
Make the expression type be Boolean, the Operator = and the Value True.

Related

SSRS - possible to share the same filter definition for a chart and a tablix?

In Excel you have the option of showing a table below your chart that shows the data used in the chart - I am trying to replicate that behavior in SSRS.
Scenario:
I have one dataset from which I want to populate two (Chart + Table) elements (so two charts and two tables). Each Chart + Table combo needs to use the exact same filter, but I don't want to manually define that exact same filter on each object (if I need to change it, I don't want to have to make the change on two entities).
Yes I know there are other ways to accomplish the same end result, such as perform the filter in the SQL, or to instead define two separate datasets, and then apply the filter on the dataset itself (so it will then cascade down to both the Chart and Table).....or in other words, I'm not asking if this is a good idea, I'm asking if it is possible. :)
Closest thing I can think of to what you want is to define the logic of your filter in custom code, and call the custom code in your two filters.
If the logic ever changes, you would only have to change it in one place.
But it's not possible to define the filter on your tablix, for instance, and then in your chart put in some kind of "use the same filter as my tablix" command.
I would add a Calculated Field that checks your criteria and gives a 1 or 0 depending on whether it meets all the criteria or not.
Field Name: MeetCriteria
=IIF(Fields!AGE.Value < 10 and Fields!status.Value = "PAID", 1, 0)
Then you just need to filter on the new calculated column:
Expression: Fields!MeetCriteria.Value
Type: INTEGER
Operator: =
Value: 1
Not quite what you want but much easier than duplicating the criteria everywhere.
For a multi-value Status parameter, you could do something like:
=IIF(Fields!AGE.Value < 10
AND INSTR("|" & Join(Parameters!Status.Value, "|") & "|", "|" & Fields!Status.Value & "|") > 0,
1, 0)

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.

Use ComboBox as Query Criteria - Boolean

I'm building a query that I'll use in a form to display a list of employees. On my form I have two comboboxes, one to filter the query by end date and one to filter by status.
The source table for the query has a Boolean field (a Yes/No field) which designates whether the employee is available or not, hence the combo to filter by status. I've run into the issue of how to use non-Boolean combo options but still have the query critera be Boolean.
I know that to use a combobox as a criteria I use this syntax: [Forms]![Form1]![Combo4], but since my combo options are "In Training" and "Available" I don't know how to convert the criteria to Boolean... is this even possible?
Example
If my user selects "In Training" from the combo (which would be equal to False on the source table), my query should use False as the criteria for that field.
After searching Google for an hour without any luck, I'm guessing this may not be possible?
Use an IIf expression to transform the combo's text value to Boolean.
IIf([Forms]![Form1]![Combo4] = "Available", True, False)
Note I assumed you want True when the combo's value is "Available" and False for anything else. If the possibilities are more complex, you could use a Switch expression to assign the correct Boolean for each possible combo value ... or use a lookup table which maps between the two.

SSRS Report - Dataset Filters

I've written a report for SSRS and Im using dataset filters with expressions to filter the report info. I seem to either have this expression wrong or the filter is not working correctly:
=IIf(Parameters!DoctorID.Value = "All" Or Parameters!DoctorID.Value = "", "*", Parameters!DoctorID.Value)
What I want to accomplish with the above code is if DoctorID = ALL or "" (blank) then I want to omit it from the filters so I return information for all doctors. However, whenever the value of DoctorID = ALL, I'm returning no rows what so ever. It should be the case that i'm getting ALL rows since DoctorID is not a specific number.
Does the "*" (star) not denote an omitting of that filter? Am I doing something wrong here?
Thanks!
The filter formula you provide is only half the equation: what is the operator and what are you comparing this to? And yes, I haven't seen SSRS use asterisk as a wildcard.
Consider putting your filter into the query for the dataset. The SQL WHERE clause can get pretty powerful. I would write your filter into the query as
...
WHERE
#DoctorID = 'All' OR #DoctorID = ''
OR #DoctorID = myTable.DoctorID
This will also let you move to a multiple value parameter pretty easily.

Adding optional filter in SSRS 2008

I am trying to add an optional filter on a text field in a report. I have tried setting it up in the dataset but it treats it as a required filter so if it is not populated, no results are returned. It needs to use the Like operator. Any advice?
As I was typing out a work-around to this problem, I realized an incredibly easy solution (now that I understand better how it works).
Here's what I did:
Since Hong pointed out that all filter conditions must be met, I reversed my thinking. I moved my existing "IN" filters to the query and fed the parameter directly to the query. Then I created by "LIKE" text filter on the report which a default value of "*" so it would immediately return everything.
Here's what I could've done:
Just the last part. Added the "LIKE" filter with a default value of "*" so it immediately returned everything.
I also agree that most of the time it's best to send the params back to SQL. Since that's not what the OP is asking, here is the best option I have found for doing this. And it is actually quite simple.
Add your parameter with the appropriate data type. Let's use the
example of a "City" in this case (a text/string field).
Check "Allow Nulls" on the parameter.
Add a filter to either a tablix, table or dataset.
In the expression, select the field you want to filter on. Select the appropriate operator, in my example of a data set with Cities, in the Value put in this:
=IIF((Parameters!City.Value Is Nothing), Fields!City.Value, Parameters!City.Value)
I don't think you can make an optional filter in DataSet Properties/Filters, adding filters there means returning results that match ALL filter contiditions, so it is "AND" logical relation among all filters, not "OR".
My sugguestion is to use filter in query designer of the dataset, where you can define "OR" relations to filter out data. For instance: Your_Text_Field="SomeValue" OR Your_Text_Field is Empty.
Although I agree that most of the time it is best to send the parameters back to the stored procedure or data layer to reduce the amount of data returned, I have a case where it is just as easy to do the parameter handling in the RDL file via a filter. Due to this unique situation I found this solution which gives you a way to create an Optional filter in the RDL file.
http://www.andrewshough.com/development/sqlserver/ssrs/optional-filter-in-ssrs/
It is a great blog post with easy step by step instructions on how to create an optional filter.
Please Note: This is NOT my blog but I though this solution was great for what I needed and I hope it helps someone else when they google for "optional filter in SSRS" like I did.
I found a post which solved my problem setting the filter for a report-consumer to a) all multivalue fields being selected so the user b) could specify his/her selection if necessary.
Kasim 8 Dec 2010 8:55 AM #
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.
found on: http://blogs.msdn.com/b/bimusings/archive/2007/05/07/how-do-you-set-select-all-as-the-default-for-multi-value-parameters-in-reporting-services.aspx
(The Post came up in the comments quite in the middle.)
You can accomplish this by using an expression on the dataset filter.
Check this