SSRS 2008 Background colour based on values - reporting-services

I am trying to use this expression to change the background colour of a text box within SSRS 2008
=IIF(Fields!Score.Value <=12, "Green", IIF(Fields!Score.Value >=13, "Amber" , IIF(Fields!Score.Value >=19, "Red" ,"White")))
The result is 15 which should pull back an amber colour which it is not doing.
The thresholds for the score field are
High 19-24
Medium 13-18
Low < 12

Try to convert field value to INT, Might be expression considering this as string
=IIF(CInt(Fields!Score.Value) <=12, "Green", IIF(CInt(Fields!Score.Value) >=13, "Amber" , IIF(CInt(Fields!Score.Value) >=19, "Red" ,"White")))

Assuming 'Score' is an INT you just need to swap the tests for >= 13 and >=19 as follows:
=IIF(Fields!Score.Value <=12, "Green", IIF(Fields!Score.Value >=19, "Red" , IIF(Fields!Score.Value >=13, "Orange" ,"White")))
Also 'Amber' isn't a valid colour name so change that to something like 'Orange' too.

Related

Conditionally format certain cells of tablix

Using Visual Studio 2017 (SSDT), I have a tablix where I would like to use an expression to set the background color/fill. I would like the cells to fill gray where the:
2019 Metal is Silver and 2020 Metal is Bronze, or
2019 Metal is Gold and 2020 Metal is Bronze, or
2019 Metal is Gold and 2020 Metal is Silver.
Visually, like this:
The data set populating the tablix is:
(I added custom "Is Null" code to display zeros instead.)
I've been trying IIF statement logic but have been unable to get my desired results.
The design of the tablix is:
I'm trying to set the Fill BackgroundColor on the textbox here with an expression:
...using something like:
=IIF(
Fields!METAL_YEAR_2020.Value="Bronze" AND
(Fields!METAL_YEAR_2019.Value = "Silver" OR Fields!METAL_YEAR_2019.Value = "Gold")
, "Gray"
, "Transparent"
)
If I leave out the OR condition I can fill one intended cell, but I don't know how to account for the three cells.
So, this code below sets one cell but can I nest or SWITCH to set the three cells I want?
= IIF(
(
(Fields!METAL_YEAR_2019.Value = "Silver" and Fields!METAL_YEAR_2020.Value = "Bronze")
OR (Fields!METAL_YEAR_2019.Value = "Gold" and Fields!METAL_YEAR_2020.Value = "Bronze")
OR (Fields!METAL_YEAR_2019.Value = "Gold" and Fields!METAL_YEAR_2020.Value = "Silver")
)
, "Gray", "White")
since there is no data where you get the null values (not only the integer value is absent, but all values, you have to refer to the group value, which is in the textbox)
= iif(
(cstr(ReportItems!Metal_2019.Value) = "Silver" AND cstr(ReportItems!Metal_2020.Value) = "Bronze") OR
(cstr(ReportItems!Metal_2019.Value) = "Gold" AND (cstr(ReportItems!Metal_2020.Value) = "Silver" OR cstr(ReportItems!Metal_2020.Value) = "Bronze")),
"Gray","Transparent")
found at

Conditional Field Background Color in Report Builder 3.0

i have this Conditional Field
=iif(Fields!ENTRADA.Value>Fields!Hora_IN.Value,"Yellow", "white")
But i wanna Add another condition:
i have another field: abrv
What i wanna do is:
Iff abrv.Value=F.C and (DATEDIFF( MI , #ENTRADA.Value , #Hora_IN.Value ) )>15 "Yellow", "white"
ELSE =iif(Fields!ENTRADA.Value>Fields!Hora_IN.Value,"Yellow", "white"),
Can i do that?
Yes you can do that. You actually still only have 2 potential outcomes, since two of those result in Yellow, so you can do this within one IIf statement:
=IIf(
(Fields!abrv.Value = "F.C" and datediff(MI, Fields!ENTRADA.Value, Fields!Hora_IN.Value) > 15)
or
(Fields!ENTRADA.Value > Fields!Hora_IN.Value),
"Yellow",
"White"
)
Or, you can use Switch, since you are checking 3 different conditions.
=Switch(
Fields!abrv.Value = "F.C" and datediff(MI, Fields!ENTRADA.Value, Fields!Hora_IN.Value) > 15, "Yellow",
Fields!ENTRADA.Value > Fields!Hora_IN.Value, "Yellow",
true, "White"
)
By putting "true" as the condition on the last line of the switch, that line basically acts as an "else", so anything that did not meet one of the conditions above it will get that value.

Change text box color in SSRS based on value

I am creating a SSRS report and I have column named Priority and I want to change background color of that particular box based on the value.
This is what I have tried
=SWITCH(Fields!Priority.Value = Critical, "Red", Fields!Priority.Value = High, "Green", Fields!Priority.Value = Average, "Yellow", Fields!Priority.Value = Low, "Blue")
Error:
The BackgroundColor expression for the text box ‘Priority1’ contains an error: [BC30451] Name 'Critical' is not declared.
Thank you
The values on the right side of your equal signs need to be in double quotes.
=SWITCH(Fields!Priority.Value = "Critical", "Red", Fields!Priority.Value = "High", "Green", Fields!Priority.Value = "Average", "Yellow", Fields!Priority.Value = "Low", "Blue")
EDIT: Just to add a little description in case it's not clear: you need those double quotes since you're comparing to those strings. Bare words in expressions are assumed to be keywords, so when it gets to the word Critical and can't find any keyword associated with that, it doesn't know what to do. If you were comparing numbers, you would not need the quotes, but since you are dealing with strings in this case, you do.

ssrs show text different colour when field matches with another

I have a requirement to show different text color when one field matches with another three different fields.
I have written below expression,
=IIF(
Fields!OrderBlockLetter.Value = Fields!InstitutionBlockLetter.Value, "Green",
or Fields!OrderBlockLetter.Value = Fields!DegreeBlockLetter.Value, "Orange",
or Fields!OrderBlockLetter.Value = Fields!AwardBlockLetter.Value, "Blue", "No Color")
But its not working. When saving this code it gives error.
I am using SSRS report builder.
You can't use IIF with OR like that. IIF just returns a value if the expression is true and another if it's false. You can nest IIFs to get the desired results but using SWITCH is much simpler. Try this... (not tested but should be close enough)
=SWITCH
(
Fields!OrderBlockLetter.Value = Fields!InstitutionBlockLetter.Value, "Green",
Fields!OrderBlockLetter.Value = Fields!DegreeBlockLetter.Value, "Orange",
Fields!OrderBlockLetter.Value = Fields!AwardBlockLetter.Value, "Blue",
True, "Black"
)
As switch returns on the first true expression, if all the others fail, the final expression is always True so the "Black" will be returned.
EDIT: Actually, "No Color" is not a valid font. You either need to pick black (the default color), or white (to give the appreance of there not being text there)

ssrs show text different colour when field matches with another field

I have a requirement to show different text color when one field matches with another three different fields.
I have written below expression,
=IIF(Fields!OrderBlockLetter.Value = Fields!InstitutionBlockLetter.Value or Fields!DegreeBlockLetter.Value or Fields!AwardBlockLetter.Value, "Green", "No Color")
But its not working.
I am using SSRS report builder.
That's not how the OR works.
You would need to use something like..
=IIF(Fields!OrderBlockLetter.Value = Fields!InstitutionBlockLetter.Value or Fields!OrderBlockLetter.Value = Fields!DegreeBlockLetter.Value or Fields!OrderBlockLetter.Value = Fields!AwardBlockLetter.Value, "Green", "No Color")