SSRS Switch text box - reporting-services

I have a requirement where I have a document called 'F' 'R' and 'C' (#DocNumber)
When I type this into my report, I have three fields that get populated. I want to condense this into 1 text field and create an expression to say
Iif document = 'F',
show Fields!FRSDisplay.Value,
Iif document = 'R',
show Fields!RSDisplay.Value,
Iif document = 'C',
show Fields!CSDisplay.Value,
NULL()

Using IIF() you should easily be able to accomplish this. You're basically there.
IIF(document = 'F', Fields!FRSDisplay.Value,
IIF(document = 'R',Fields!RSDisplay.Value,
IIF(document = 'C',Fields!CSDisplay.Value,NOTHING)))

The easiest way to accomplish this would be with the SWITCH statement. Try the following expression:
= SWITCH(Parameters!DocNumber.Value = "F", Fields!FRSDisplay.Value,
Parameters!DocNumber.Value = "R", Fields!RSDisplay.Value,
Parameters!DocNumber.Value = "C", Fields!CSDisplay.Value,
true, "")
This will cycle through the conditional statements and display the correct field as required. The final true will capture any DocNumber value that does not match and set the field to nothing.

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

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

SSRS how to have two different condition in Action Property

I am working in a SSRS that needs to link a report based on the value in a textbox.
I have tried:
=IIf(Fields!Factors.Value = "Touched Leads","SCPL",Nothing)
Which works fine, but when I try to add another condition like this:
=IIf(Fields!Factors.Value = "Touched Leads","SCPL",Nothing) OR
IIf(Fields!Factors.Value = "TOTAL","Disposition",Nothing)
Then it does not link any report. How do I do this right?
What you are trying does not work correctly as the IIF statements are not nested and what it is doing is:
IIF(this, true part, false part) OR IIF(this, true part, false part)
So when Fields!Factors.Value = "Touched Leads" the expression evalutes to SCPL OR Nothing which isn't valid.
Alternatively you could use SWITCH which has a nicer syntax, the final True statement is your catch all
=SWITCH(
Fields!Factors.Value = "Touched Leads", "SCPL",
Fields!Factors.Value = "TOTAL", "Disposition",
True, Nothing
)
I think that the expression you need will look like this:
=IIf(Fields!Factors.Value = "Touched Leads","SCPL",
IIf(Fields!Factors.Value = "TOTAL","Disposition",Nothing))
This checks the first condition ("Touched Leads"), if that is true, link the SCPL report, otherwise check the "TOTAL" condition. If that one is false, return Nothing.

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.

Partial evaluation boolean formula in sage

Is there any way to evaluate a boolean formula in partial form. I make this question because when I run
import sage.logic.booleval as booleval
t = ['&', 'a', 'b']
dd = {'b' : False}
print booleval.eval_formula(t, dd)
I get KeyError: 'a', when is obvius that t is False.
I think there isn't.
If you look up into the source file, which is /usr/lib/python2.7/site-packages/sage/logic/booleval.py on my computer, you can find that sage first transform 'a' and 'b' into True/False, for they need not to be. So they must all be defined.