Hi there,
I have to admit i really do struggle with nested iff statements within ssrs.
Please can someone help me?
I have a field i want to check if it is ‘Non Brittle’ , then I want to check if a boolean field is true, then rather than showing 1, i want it to show Pass.
Sounds simple right?
Well, not for me it seems…i hate nests!
So this is the statement:
Test it and if works, I’ll do some refactoring by getting the easy stuff out of the way first. So let’s say I want the value blank for all the Brittle values:
@Mark_Wonsil - How would you know if that is “working”? The only thing that “tests” is if the AttrDesc is a string (or can be compared to a string).
@carla - I’m not sure you need to do the conversion of Fields!ResultValue.Value. And even if you did, the snippet Iif(IsNumeric(Fields!ResultValue.Value), Val(Fields!ResultValue.Value), Fields!ResultValue.Value)
checks to see if ResultValue is a number, and if it is then use the Val() function. The VAL() function is typically used to convert a string to a number. If ResultValue is a number, why would you try to convert it again?
What the other iff nests are doing is checking if the fields have other values, like if is was a 99999 then it shouldnt show, if its a ozone resistance then do same as what were trying to achieve now. The fields are part of the inspection results attributes and so could have any type of value.
That will confirm what AttrDesc actually is. I added the "'" to before and after so you can be sure there are no leading or trailing spaces. If there was a trailing space, then the output would be: 'Non Brittle ' (note the space between “Brittle” and the single quote). And that would not be equal to the string "Non Brittle"
Also, if you’re copying text right from this page, sometimes the double quotes will be converted to fancy quotes. Like the difference bewteen: "text" and “text”
Note that I comverted ResultValue to a number and then compared it to the number 1, instead of the string "1".
Also, to be sure we understand the desired logic, does the following table agree with what you want?
AttrDesc ResultValue Output
============= =============== ============
"Non Brittle" "1" PASS
"Non Brittle" 1 PASS
"Non Brittle" "0" 0
"Non Brittle" 0 0
"Non Brittle" "2" 2
"Non Brittle" 2 2
"Brittle" X (whatever X is)
"Fragile" X (whatever X is)
[quote=“ckrusen, post:16, topic:78119”]
That will show either PASS or the value of ResultValue (when it is not 1), when AttrDesc is Non Brittle
[/quote] Correct
[quote=“ckrusen, post:16, topic:78119”]
If AttrDesc is anything but Non Brittle then the field will be blank.
[/quote] Incorrect - i want it to show the value for that attrdesc
In below screenshot of the report you can see the attrdesc can be a number of different descriptions, only when it is a Non Brittle do i want it to convert this boolean from a 1 to show PASS