SSRS IIF Filtering on Tablix - reporting-services

I am working with SSRS and have a tablix that needs certain rows excluded if a value in a multi-value parameter is not selected. For example, the multi-value parameter is 'Include Loss' and the values are 'Yes' and 'No'.
So if the user selects 'No', then I want the tablix to exclude rows where Description field is equal to the text "Loss Transaction".
I am trying to write an expression to filter on the tablix as follows, but having no luck.
=IIF(Parameters!IncludeLoss.Value="N", Fields!Description.Value, NOTHING)
and use '<>' for the 'Operator' and then:
="Loss Transaction"
I get the error 'Failed to evaluate the FilterValue of the Tablix'. Any suggestions? Thanks in advance!

Filters have an implicit AND relationship - that is, all the conditions have to be True for the filter to take effect.
Accordingly, you can have two filter conditions set:
=Parameters!IncludeLoss.Value is equal to N (add a second condition)
=Fields!Description.Value is equal to ="Loss Transaction"
Alternatively, for complex conditions (or conditions involving OR or Null which aren't supported in a standard filter) you can just use one condition and set that condition's expression to something more complex that evaluates to a boolean and test that against True. For example:
=Parameters!IncludeLoss.Value = "N" AND Fields!Description.Value = "Loss Transaction"

Related

How to filter a tablix based on paramater but no filter when paramater is null?

I've a tablix with data that comes from a dataset , there is a column called Productgroup and there might be some users that would like to apply a filter on it.
I'm trying to build an ssrs expression that will filter my tablix on that specific column but only when the parameter called #Filter is not null , if null , it does not need to apply filter
I've tried
Expression: Productgroup
Operator: like
Value: =IIF(IsNothing(Parameters!Filter.Value), false, Fields!ProductGroup=Parameters!Filter.Value)
Nothing seems to works :(
First of all, it's best to send your parameters to your dataset and filter on the server, rather than bring back ALL of the data and filter on the client side. So that means parameterizing your stored procedure, or using a WHERE clause to filter the table/view you're connecting to.
If you stick with this approach:
You want your Expression to be "ProductGroup".
You want your Operator to be "=".
You want your Value to be =IIF(IsNothing(Parameters!paramFilter.Value), Fields!Productgroup.Value, Parameters!paramFilter.Value)
What you're doing is saying if the parameter is empty, I need the ProductGroup to be equal to the ProductGroup. That's always true. But if the parameter is not empty, the ProductGroup has to be equal to the parameter value.

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.

SSRS Expression for Image

I have a requirement to display either of two images based on a condition. The expression I have used for the image is as below.
Image1 =IIF(Fields!Field1.Value= 269, "checked", "unchecked")
Image2 ==IIF(Fields!Field1.Value= 270, "checked", "unchecked")
The dataset returning the values for Field1 can return more than 1 rows but the above expression takess the value only from the 1st row that the dataset returns. How can I modify by expression so that it checks all the rows that my dataset returns i.e. is there any way to iterate through all the rows returned by the dataset and write an expression.
You can nest an IIF condition in an aggregate to check against all values in the scope:
=MIN(IIF(Fields!Field1.Value= 269, "checked", "unchecked"))
In this expression, either "checked" or "unchecked" is being returned for each Field1.Value. If one or more of those values is "checked", "checked" will be returned because "checked" is alphabetically less than "unchecked".
Other aggregate functions can be used with a nested IIF to check against all records in a scope, but this one seems to be the simplest for what you are trying to do here.

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 2005: how to write an IIF statement to check whether values are in a parameter list

In SSRS 2005, I'm trying to set up an expression to return true or false, according to whether the value of one of the ReportItems is in a list of (possibly multiple) values selected by the user from a list when the report is run.
Here's the expression so far:
=iif(Trim(ReportItems!Category_2.Value) = Trim(Parameters!Category.Value(0)), False, True)
You can see that True and False in the expression are reversed - this is because it's to control the 'Hidden' property of the row, and I want to NOT hide rows where the value is in the list.
The expression works fine when choosing single values for the parameter, but for multiple values, it only displays the results for the very first.
Hope you can help.
Try using
=iif(Trim(ReportItems!Category_2.Value) = Trim(Parameters!Category.Value), False, True)
Many thanks for your help. These multiple values were really bugging me, and I never managed to get Trim to work properly, so I ended up using the following two-stage solution, instead:
(1) In the SQL 'SELECT' statement, I defined a new value called 'InCategory', assigning it a value of 1 or 0 according to whether the Category was one of the inputted Categories or not:
CASE WHEN Category IN (#Category) THEN 1 ELSE 0 END AS 'InCategory',
(2) Then in SSRS, my expression for the 'Hidden' in the report became simple, hiding the row if the sum of 'InCategory' for that row was 0:
=iif((Sum(Fields!InCategory.Value) = 0), True, False)
Thank you again for your help - I much appreciate it, and will use this site again.