#ERROR Help, SSRS Report Builder, IIF w/ LOOKUPSET - reporting-services

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")

Related

SSRS Textbox expression modifying

i designed a tablix report, i have a text box called Student-Attendance which dispaly the information below.
Student_Attendance
Sick
Absence
Present
I have tried to use IIF statement in order to show it as S,A,P. Other than "IIF" is there anything i could use in order to get my result.
IIF (Fields!Student_Attendance.value = "Sick", "S" ) and
IIF(Fields!Student_Attendance.value = "Absence" , "A")
IIF Takes 3 arguments
The condition (if field = value)
What to return if true (e.g. "S")
What to return if false - you are missing this
If you want to use IIF then you have to nest the IIFs
=IIF(Fields!Student_Attendance.value = "Sick", "S", IIF(Fields!Student_Attendance.value = "Absence" , "A") )
What might be simpler is SWITCH especially if you have more than a few options, something like this
=SWITCH (
Fields!Student_Attendance.value = "Sick", "S",
Fields!Student_Attendance.value = "Absence", "A",
Fields!Student_Attendance.value = "Present", "P"
)

SSRS Lookupset sum problem when one or more value are nothing

I got a little problem with Lookupset on a SSRS Report.
The report has a father-child structure in the group section and the datasets come from different tabular.
The problem occurs when one of the Product from Dataset1 is missing on Dataset2, the entire sum returns 0.
I tried this VB code in order to sum up all the values the Lookupset is able to return.
Function SumLookup(ByVal items As Object()) As Decimal
If items Is Nothing Then
Return Nothing
End If
Dim suma As Decimal = New Decimal()
suma = 0
For Each item As Object In items
suma += Convert.ToDecimal(item)
Next
Return suma
End Function
I expected the sum of every Product Lookupset is able to retrurn me but it is just returning 0 if one of the Products is missing in Dataset2.
Is there a way to manage the Nothing returned by Lookupset?
Sorry for the formatting and my poor english and thanks in advance!
I would handle this by checking for the value in your LOOKUPSET expression that SumLookup is summing.
I assume that your expression looks something like this:
=CODE.SumLookup(LookupSet(Fields!ProductID.Value,
Fields!ProductID.Value,
Fields!Price.value,
"Dataset2") )
Use an IIF with ISNOTHING to check for the NULL values and set them to zero:
=CODE.SumLookup(LookupSet(Fields!ProductID.Value,
Fields!ProductID.Value,
IIF(ISNOTHING(Fields!Price.value), 0.00, Fields!Price.value),
"Dataset2") )
The function returns a Decimal datatype. By a Decimal datatype Nothing and 0 are the same. You can test this.
Put a tablix into your report with year from 2017 to 2019. Then put the year in a column of the tablix as a number format, then write the following expression in the detail textbox:
=CDec(IIF(CDec(Fields!Year.Value) = 2017, 0, Nothing))
After executing your report you will notice that every value in the year column is 0.
The same goes for the check. Both of these expressions will always return Yes. I basically check for 0 and the second one for for Nothing:
=IIF(CDec(IIF(CDec(Fields!Jahr.Value) = 2017, 0, Nothing)) = 0, "Yes", "No")
=IIF(CDec(IIF(CDec(Fields!Jahr.Value) = 2017, 0, Nothing)) = Nothing, "Yes", "No")
But remember your textbox/column has the be a number format.
So if you want to return Nothing and you display it in a number format textbox, it will show you a 0.

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

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.

How to hide a row in ssrs using a multi select parameter

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.