I have a field in a report with 4 potential values, "A", "B", "C" & "D".
The following code makes the font color "red" for "C" and "D" and "black" for all other values. How do I add another statement to make the color "green" for value "A"?
<Color>=IIF((Fields!DFEE_condition.Value = "C") or (Fields!DFEE_condition.Value = "D"),"Red","Black")</Color>
Thanks
Have you tried to reuse IIF statement like this :
<Color>=IIF((Fields!DFEE_condition.Value = "C") or (Fields!DFEE_condition.Value = "D"),"Red",IIF((Fields!DFEE_condition.Value = "A"),"Green","Black"))</Color>
You could convert [A..D] to [1..4] and Choose():
color = choose(asc(Fields!DFEE_condition.Value)-64, "Green", "Black", "Red", "Red")
(If you can use statements, you would Select Case)
You need to write nested iif's ;)
result = IIF(condition1, value_if_true, IIF(condition2, value_if_true, value_if_false))
Try something like this:
<Color>
=IIF((Fields!DFEE_condition.Value = "A"), "Green", IIF(Fields!DFEE_condition.Value = "C") or (Fields!DFEE_condition.Value = "D"), "Red", "Black"))
</Color>
Related
Like the title says, I'm just trying to use OR and AND conditions within my IF statement in access, for example:
iif(A=" " OR A=0 AND B>=2,"Test1","Test2")
I'm trying to figure out what the correct way to write this would be.
Thanks in advance.
I think you just want parentheses:
iif( (A = " " OR A = 0) AND B >= 2, "Test1", "Test2")
However, this does not really make sense. Is A a number or a string? If a string, then all comparisons should be to strings:
iif( (A = " " OR A = "0") AND B >= 2, "Test1", "Test2")
If both are numbers, then the comparison to " " is meaningless. You probably want to compare to NULL:
iif( (A is null OR A = 0) AND B >= 2, "Test1", "Test2")
I am pretty new to R so please excuse me if I got this wrong.
I am trying to change a dashed linetype of a geom_hline in ggplot2 to a solid one.
Any help is much appreciated!
Usually this is easily done with changing linetype = "dashed" to linetype = "solid". But since I have to use linetype for the text in my legend I cannot do this. Also adding linetype = "solid" after color results in
Error in [[<-.data.frame (tmp, i, value = c("blue", "blue")) :
Replacement has 2 lines, Data has 1`
This is the code that I am trying to adjust:
geom_hline(aes(yintercept = 5, linetype = "Title 1"), colour = "blue") +
geom_hline(aes(yintercept = 2, linetype = "Title 2"), colour = "blue") +
scale_linetype_manual(name = "", values = c(2, 2),
guide = guide_legend(override.aes = list(color = c("blue", "blue"))))
I am trying to figure out how to use the select case for the problem below.
In cell A1 I will have the text "white" or "black"
In cell B1 is a number
In cell C1 is the result i am looking for to be shown
If A1=white and B1<2 then C1=25
If A1=white and B1>=2 then C1=49
If A1=black and B1<2 then C1=14
If A1=black and B1>=2 then C1=30
You could use the following:
Select Case True
Case Range("A1") = "white" And Range("B1") < 2: Range("C1")=25
Case Range("A1") = "white" And Range("B1")>=2: Range("C1")=49
Case Range("A1") = "black" And Range("B1") < 2: Range("C1")=14
Case Range("A1") = "black" And Range("B1")>=2: Range("C1")=30
End Select
I have a report in which one of the columns returns a DB field which can be 1 of 3 possible outcomes - 1, 0 or blank/"".
From what I can see, I think the problem here is that the field is blank rather than a NULL value, so any expressions I use seem to result in a #Error.
So far I have managed two different expressions which yield two halves of the results I need:
=IIF(Fields!Field1.Value = 1, "Yes", IIF ({Fields!Field1.Value = 0}, "No", "Unanswered"))
The above gets me 1 = "Yes", 2 = "No" and "" = #Error.
=IIF(Fields!Field1.Value="","Unanswered",Fields!Field1.Value)
This second one gets me 1 = 1, 0 = 0 and "" = "Unanswered".
Is there a way I can combine these and have the results appearing as 1 = "Yes", 0 = "No" and "" = "Unanswered"?
Any advice is appreciated!
Try using this SWITCH expression.
=SWITCH (
Fields!Field1.Value = 1, "Yes",
Fields!Field1.Value = 0, "No",
True, "Unanswered"
)
The final True acts like and else.
If this does not work, you may need to cast the field to text and check as follows
e.g. CStr(Fields!Field1.Value) = "1", "Yes",
I tried to incorporate the following into SSRS but failed.
If XXX = “A” then display “AT”
Else if XXX = “B” then display “BEE”
Else if XXX = “C” then display “CAR”
Else display “Other”
I tried
=Switch(
Fields!XXX.Value = "A", "AT",
Fields!XXX.Value = "B", "BEE",
Fields!XXX.Value = "C", "CAR", "Other")
You almost had it. For every output in the Switch function must be paired with a condition. Just make your last condition evaluate to True.
=Switch(
Fields!XXX.Value = "A", "AT",
Fields!XXX.Value = "B", "BEE",
Fields!XXX.Value = "C", "CAR",
True, "Other"
)
You want something like this:
=iif(Fields!XXX.Value = "A", "AT", iif(Fields!XXX.Value = "B", "BEE", iif(Fields!XXX.Value = "C", "CAR", "Other")))
[check the parens in the expression builder]