How to hide a row in ssrs using a multi select parameter - reporting-services

I need to be able to conditionally hide a row in SSRS 2005 based on a Multi Select Parameter. I need to be able to hide the row if the multi parameter = "CS", but if the Multi select Parameter is "CS" and "Sales" then I need to see the row.
I've tried this formula:
=IIf((Parameters!Level_4.Value(0) = "CS"
And Parameters!Level_4.Value(0) = "Sales"),false ,True)
=IIF((Parameters!Level_4.Value(0) = "CS"), True, False)
But it does not work...

Try this:
=Switch(
Array.IndexOf(Parameters!Level_4.Value, "CS")>-1 AND
Array.IndexOf(Parameters!Level_4.Value, "Sales")>-1,false,
Array.IndexOf(Parameters!Level_4.Value, "CS")>-1,true
)
Note multivalued parameters can contain one or multiple values which are stored in an array data type. So if you select a value in your report it will be stored in the 0 index of the array, if you select one more value it will be stored in the 1 index and so on.
Example: "CS" value is stored in Level_4.Value(0) and "Sales" is stored in Level_4.Value(1).
The expression I proposed will check if both values were selected and return true in that case, otherwise if only "CS" is selected it will return false.
UPDATE: Alternative to IndexOf support
=Switch(
InStr(Join(Parameters!Level_4.Value, ","),"CS")>0 AND
InStr(Join(Parameters!Level_4.Value, ","),"Sales")>0,false,
InStr(Join(Parameters!Level_4.Value, ","),"CS")>0,true
)
Let me know if this helps.

Related

ssrs filter tablix expression that will use parameter value to filter tablix

ssrs filter tablix expression that will use parameter value to filter tablix
Id like to filter my tablix based on one parameter with 3 possible values to select from.
Person
Dog
Both
Then filter the tablix by field: Person, Dog, Both...
---update
Tablix Filter by parameter values. Goal include ALL
1 Parameter has 3 options (not multi select). PERSON, DOG, ALL.
I have a field built called FILTER that places "ALL" in the cells.
Otherwise its between the field CLIENT_TYPE "PERSON" or "DOG"
expression:
Fields!CLIENT_TYPE.Value
Value
Parameters!CLIENT_TYPE.Value
This works for "PERSON" and "DOG" only. Dopes Not work for "ALL"
What would be the Expression and Value to filter the tablix according to parameter...
could I trick the "ALL' into excluding nothing?
expression
IFF(Parameters!CLIENT_TYPE.Value = Fields!CLIENT_TYPE.Value or Parameters!CLIENT_TYPE.Value = Fields!FILTER.Value
, "include"
, "Exclude")
Value
=Parameters!CLIENT_TYPE.Value
RESOLUTION:
expression
=(Fields!CLIENT_TYPE.Value = Parameters!CLIENT_TYPE.Value)
OR
(Parameters!CLIENT_TYPE.Value = Fields!FILTER.Value)
value
=true
you will click on your tablix properties -> visibility and then pop and expression like so
iif(parameters_p1.value = 'Person',True,False). Keep in mind that if you have a select all option i.e. param can accept multiple values This solution WILL NOT WORK. It will only accept 1 value at a time and render result for that.
You'll want to compare your field with the parameter.
For a filter expression, you'd have something like
=IIF(Fields!YOUR_FIELD.Value = Parameters!YOUR_PARAMETER.Value OR Parameters!YOUR_PARAMETER.Value = "Both", 1, 0)
The set the type to integer and the value to 1. This will assign the value of 1 to records that your field matches the parameter or the parameter is both. This assumes that there are no other options however.
You could also map the parameter to your query and filter the query instead of using a filter on the dataset or tablix.
WHERE (YOUR_FIELD = #YOUR_PARAMETER or #YOUR_PARAMETER = 'Both')
1 Parameter (3 options): Person, Dog, All... created a field in sproc: FILTER which holds "ALL" for every cell.
expression
=(Fields!CLIENT_TYPE.Value = Parameters!CLIENT_TYPE.Value)
OR
(Parameters!CLIENT_TYPE.Value = Fields!FILTER.Value)
value
=true

#ERROR Help, SSRS Report Builder, IIF w/ LOOKUPSET

I'm trying to compare 2 rows of data in the form of %'s. I generate and it "#Error".
=IIF(Fields!Grade.Value = "ONGRADE" > LookupSet(Fields!Grade.Value = "ONGRADE", Fields!grade.Value = "ONGRADE", Fields!grade.Value = "ONGRADE", "Previous3Week"), "UP" ,"DOWN")
There are two DataSets.
You are using IIF incorrectly. IIF just looks at a comparison and returns the first value if TRUE and the second value if false.
=IIF(1 = 2, True, False)
Which reads as
If 1 = 2 then return TRUE else return False
You are also using LookUpSet incorrectly. The first LookUpSet argument is your current dataset field that you want to compare, the second argument is the field from the first that you want to compare to - since your using the same dataset, they might be the same. The third LookUpSet argument is the field that you want to return (you know the ONGRADE field, what value do you want back?).
Your expression reads, if Grade = ONGRADE > LookupSet(blah blah) ...
What is the value field that you want to compare? Assuming it's Fields!GRADE_VALUE.Value, your IIF might be like
=IIF(Fields!Grade.Value = "ONGRADE",
IIF(Fields!GRADE_VALUE.Value >
LookupSet(Fields!Grade.Value, Fields!grade.Value, Fields!GRADE_VALUE.Value", "Previous3Week"),
"UP" ,
"DOWN"),
"Not ONGRADE")
If you want all GRADE types (not just ONGRADE) compared, it would be simpler:
=IIF(GRADE_VALUE > LookupSet(Fields!Grade.Value,
Fields!grade.Value,
Fields!GRADE_VALUE.Value,
"Previous3Week")
, "UP"
,"DOWN")

Hiding table or assigning temp data based on visibility expression ssrs 2008

I have a table in ssrs 2008. This table has a row visibility expression like:
=IIF(max(Fields!VExpected.Value) <> "", 1, 0) +
IIF(max(Fields!MExpected.Value) <> "", 1, 0) +
IIF(max(Fields!PExpected.Value) <> "", 1, 0) = 3, false, true)
Sometimes the datasource returns no data, or the returned data is not matching with this expression. In this case what I see is that a table with borders and column names but no data on it like:
id Vex Mex Pex
However, I want to show it as
id Vex Mex Pex
- - - -
Or if possible:
id Vex Mex Pex
No Data
Another question is, is there any way to hide the complete table if there is no returning data or any matching data with the expression?
Thanks
You can use CountRows function to determine how many rows your dataset is returning. If it is zero hide the table otherwise show it.
=iif(CountRows("DataSetName")=0,true,false)
Replace DataSetName by the actual name of your dataset.
For not matching expression data you can use the this expression.
=IIF(
max(Fields!VExpected.Value) <> "" AND
max(Fields!MExpected.Value) <> "" AND
max(Fields!PExpected.Value) <> "",False,True
)
The whole expression for matching expression and no rows cases could be something like this:
=Switch(
CountRows("DataSetName")=0,true,
max(Fields!VExpected.Value) = "",true,
max(Fields!MExpected.Value) = "",true,
max(Fields!PExpected.Value) = "",True,
true,False
)
Supposing VM, ME and PE expected values are numeric type I'd use ISNOTHING() function to determine when null values are being returned.
=Switch(
CountRows("DataSetName")=0,true,
ISNOTHING(max(Fields!VExpected.Value)),true,
ISNOTHING(max(Fields!MExpected.Value)),true,
ISNOTHING(max(Fields!PExpected.Value)),True,
true,False
)
Additional you can set a message when no rows are being returned from your dataset. Select the tablix and press F4 to see properties window. Go to NoRowsMessage property and use an expression to say your users there is no data.
="There is no data."
In this cases the tablix will not appear in your report but the message you set will be rendered in the location where the tablix should be.
Let me know if this helps.

SSRS Enable/Disable filter based on parameter Value

I have a report parameter of boolean type.
If the value is true, a filter needs to be applied to a dataset, and if false it should not filter.
Sounds simple, but can't figure out..
Any suggestions?
In your dataset query you can add logic like:
WHERE
(
#MyBooleanParam = 1 AND <filter code>
)
OR
(
#MyBooleanParam = 0
)
So if the parameter is True, then the filter logic is applied in the query, if the parameter is false then no filter is applied.
I'd use Nathan's but an alternative would be to set up your filter as normal but wrap the expression in an IIf function that short circuits the filter:
=iif(parameter!myboolean.value = 1, parameter!myfilter.value, fields!field_im_filtering.value)

SSRS multivalue parameter display

Let me know how to do this in SSRS:-
If user selects more than one values of a multivalue parameter then display "Multiple" in a textbox
else if the user selects only one value then display that value in the textbox.
There are several ways you can do it. first you can check if the specific Parameter is multivalue or not:
=Parameters! <MultivalueParameterName> .IsMultiValue
If above return True the you can check how many selections are made as below:
=Parameters! <MultivalueParameterName> .Count
Finally if above line return more then 1 then you know that multiple values are selected and set "multiple" as results and if result is 1 then show the exact value as result. The function will look like as below:
If parameter.IsMultiValue then
if parameter.count() > 1
s = "Multiple"
Else
s = parameter.Value
End If
Return s
You can use below expression:
=iif(Parameters!ParameterName.Count>1,"Multiple",Parameters!ParameterName.Value(0))