SSRS column background color formatting not working - reporting-services

I have the following requirement:
A column has negative values and NA values as well. The negative and NA value cells should be "Red" and other cells should be "light grey". I have written the following expression for this:
=IIF(Fields!BaseDOS.Value ="NA" OR Fields!BaseDOS.Value < 0, "Red", "LightGrey")
But it is not working for NA fields. Also I am using expression to show the negative values in parentheses:
=Format(Fields!BaseDOS.Value,"##0.00;(##0.00)")
This is also not working. Please help.

You should really post each problem as a separate question.
In the background color property for the text box try:
=IIF(Fields!BaseDOS.Value ="NA" OR Fields!BaseDOS.Value < "0", "Red", "LightGrey")
BaseDos must be a string.
In the format property for the textbox you want to show parenthesis try:
#,##0.00;(#,##0.00)

Related

Conditional expression for Background color in SSRS

I have a matrix in my SSRS 2016 reporting services report. I am trying to set a conditional expression on background color for the sum(field.value). This field is formatted as a percent. Here is my expression which does not appear to have any errors:
Background Color Expression:
=Switch(Fields!PicturesbeforeFirstSignoutCount.Value<.80,"Red",Fields!PicturesbeforeFirstSignoutCount.Value >= .80 and Fields!PicturesbeforeFirstSignoutCount.Value < .95,"Yellow",Fields!PicturesbeforeFirstSignoutCount.Value >= .95,"lightGreen")
Problem: It turns everything "lightgreen" even when their textbox should be yellow's and red's in the matrix. there is one field that is highlighted as Red, but it should have been Yellow.
I tried to set this in the field property for background color expression. That just made everything "light green".
I changed it to the fill expression in the matrix Text box. Now I get mostly everything green except the one red field that should be yellow. I checked my numeric values and they are coming across in decimals points when I change the format back to number
Any help would be appreciated.
As Harry mentioned in the comments, you need to be evaluating the same expression as you are displaying.
Also you can simplify the SWITCH statement as follows.
=SWITCH(
SUM(Fields!PicturesbeforeFirstSignoutCount.Value) <.80, "Red",
SUM(Fields!PicturesbeforeFirstSignoutCount.Value) < 0.95, "Yellow",
True ,"LightGreen"
)
As SWITCH returns the first result where the expression is true, there is no need to put a range in. so if the value was 0.91 then the first expression would be skipped but the second one would be true to it would return "Yellow".
The final True acts as an "else".

Conditional format of cell with different data types in SSRS?

I am trying to add a fill color to a table that I created in SSRS. The data looks like the table as follows:
The task is whenever the value is over 7, then color the cell green, when the value is less than 7 then orange and if the value is below zero then the due time changes to a sentence as shown with ID 2 and is to be colored red.
I have achieved coloring the cells when greater than or less than 7 using the if statement on the Due(Mins) field value however, it fails to color the cell red when less than 0. I have used switch, instr functions, but haven't had any luck.
Can emphasize more. Appreciate the help.
Cheers,
Sid
=SWITCH(
Fields!Due.Value.ToString.Contains("OverDue"), "Red",
VAL(Fields!Due.Value) > 7, "Green",
True, "Orange"
)
Switch will stop when it hits the first expression that evaluates to True
So...
First we test if the value contains overdue and set red
Then we test if the value is greater than 7 and set the result to Green
The True at the end acts like an else

changing background colour with expression for time value SSRS

I have an issue with changing colour of a column through an expression. The column of which I want tot change the background colour of has a time value. The format is hh:mm, currently I am using this expression:
=IIF(Fields!FacturatieTijd.Value >= 5, "Red", "Lime")
With this expression it only changes the colour of the cells which dont have a value in it(Null). I have tried using "05:00" in my expression but that gives an error..
Regards.
It seems like you're going to want to get the hours separated from your time to compare correctly. To do that, you'll need to use the Datepart function within your IIF. Try the following expression.
=IIF(DatePart("h", Fields!FacturatieTijd.Value) >= 5, "Red", "Lime")
In theory, this should extract an integer value for the hour and compare it against 5, giving you the result you need. I haven't actually tested this, but it should work.

Change color based on date value from different dataset

I am looking for a solution to change the color of an Expression with a lookup to a second data set.
I have the following code:
=Lookup(Fields!ProjectNr.Value, Fields!ProjectNr.Value, FORMAT(Fields!CreatedDate.Value,"dd-MMM") & " - " & Fields!Subject.Value, "MeestRecenteNotitie")
I need an expression causing the color of the text to change to Red when the CreatedDate.Value is older than 21 days. It will be Orange when the CreateDate.Value is older than 14 days. The normal color must be black.
The code shown in your question is for the display value of the object. To change the color you need an additional expression on the font color of the object.
To add an expression to the font color click on the object you are modifying, then
find Font --> Color in the properties pane. Click the drop down arrow and click expression in the drop down.
Then use an expression like this one to set the color.
=Iif(DateDiff(DateInterval.Day, Fields!Test1.Value, Globals!ExecutionTime) >= 21, "Red", Iif(DateDiff(DateInterval.Day, Fields!Test1.Value, Globals!ExecutionTime) >= 14, "Orange", "Black"))
I have tried the following but get the error "The Color expression for the text box" Textbox23 "refers to the field" CreatedDate ". dataset scope Letters in the names of fields must use the correct case. "
=iif(Lookup(Fields!ProjectNr.Value, Fields!ProjectNr.Value, Fields!CreatedDate.Value, "MeestRecenteNotitie"), DateDiff(DateInterval.Day, Fields!CreatedDate.Value, Globals!ExecutionTime) >= 21, "Red", , Iif(DateDiff(DateInterval.Day, Fields!CreatedDate.Value, Globals!ExecutionTime) >= 14, "Orange", "Black"))

Unable to set Background Color for NULL values in SSRS report

I have a requirement to set Red colour for Outcome column = NULL values
Design below:
I am using below expression on the Count(StudentID) Text box:
=IIF(IsNothing(Fields!Outcome.Value), "Red", "Transparent")
For Outcome textbox, I am using this expression:
=IIF(IsNothing(Fields!Outcome.Value), "NULL", Fields!Outcome.Value)
But I am unable to see any color change.
Preview:
Can you please suggest how to resolve this?
Thanks,
AR
You can use the Me.Value function to refer to the actual value of the cell you are setting the color expression for, rather than referring to the value of a Field.
=IIf(Me.Value = "NULL","Red","Transparent")
=IIF(IsNothing(Fields!Apr.Value), "Aqua","Transparent")