Creating a Report in SSRS - reporting-services

I am attempting to create a report to change Values to Red, Yellow and Green based upon the last inspection date. Inspections are every three years if DUE is in the last inspection then I want the cell to turn red, if the last inspection has been in the last 2 years I need it green and in the year that it needs and inspection I need it yellow.
Here is what I have NOT working :)
=SWITCH(Fields!Inspection_x0020_Expires0.Value = "DUE","Red"),
(Fields!Last_Inspection.Value = "d" < 730,"Yellow")
(Fields!Last_Inspection.Value = "d" > 730,"Green")
Thank you for taking the time to help me.
Tim

Use the DATEDIFF function to compare the last inspection date to today.
DateDiff(DateInterval.Day, Fields!Last_Inspection.Value, Today) < 730

Here is what I ended up doing, I added a column Named Textbox6 and calculated the number of days with a DateDiff =DateDiff("d", Fields!Inspection_x0020_Expires0.Value, Today()) to get the number of days and then I used that value to create my background text box color
=Switch (Not(isNothing(Fields!Last_Inspection.Value)) and ReportItems!Textbox6.Value <= 729, "Green", ReportItems!Textbox6.Value >= 730 and ReportItems!Textbox6.Value <=1094 , "Yellow", isNothing(Fields!Last_Inspection.Value) or ReportItems!Textbox6.Value>1094, "Red" )

Related

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

expression to change the fill colour of textbox if the date is greater or equal to 7 days before the expected end date column

i have a report that shows a tenancies expected end date in the last column and a textbox in the column to the left that uses the expression =DateAdd("d", -7, Fields!exp_tncy_end.value) to show the date 7 days before the expected end date so if the expected end date was 13/09/20 then textbox21 would display 6/9/20
many of these expected end dates are way in the future
what i would like to happen is that as we approach the week that the exp_tncy_end date is due i would like the date in textbox21 to change to red, see circled example below
example of report
can anyone help with an expression that would achieve this?
regards
Kieran
Set the color property in the textbox you want to change to this...
=IIF(DateDiff(DateInterval.Day, Today(), Fields!exp_tncy_end.Value) <=7, "Red", "Black")
Note that this will calculate the based on the day number, not a 24 hour period so you might want to adjust the number of days you check for to suit your specific needs.

How to alternate rows after each 2 row background color in SSRS

I am trying to alternate every 2 rows background color from white to blue as per below design in SSRS:
I have tried the below expression but it does not give the expected result:
=IIf((RowNumber(NOTHING) Mod 4) < 3 , "Blue", "Transparent")
Has anyone ever done anything similar and is there a way to achieve this?
I've just tested the following and it works on a simple table. If it does not work for you, please share your table/matrix design including any row or column groups.
=IIF(((RowNumber(Nothing)-1) Mod 4) < 2 , "Blue", Nothing)
This simply offsets the mod calculation by 1 as the first row is 1 so we get a sequence of 0,1,2,3,0,1,2,3....
I find that adding a new column with the mod expression helps debug things like this. SO I would add a new column with =(RowNumber(Nothing)-1) Mod 4 as the expression and see what it returns.

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.

How to Add indicators in Report Builder

I am trying to add an indicator in Report Builder to show on my report using 2 fixed conditions. the first condition is if the description of a field = "Compensation", the second being if a field date is >= Now(). It should then go red after 5 days.
I have added the indicator and in the Value and States tab, for Value I have added =(Fields!Description.Value ="Compensation")
For the indicator: Color Expression is "Yellow"
Start expression is =(fields!StartDate.value >=Now())
End expression is =(fields!StartDate.Value =Now()+5)
when I run the report, where the indicatr should be, I get text that reads "An error has occurred during data evaluation of the GaugePanel'GaugePanel5'.
Hope I've explained in enough detail.
Is anyone able to offer any advice on indicators please?
Thanks
I ended up using an expression under fill in Textbox Properties instead of adding an indicator which is giving me the required results. Example =IIF(Fields!ComplaintStageDescription.Value = "Stage0", "yellow", IIF(Fields!ComplaintStageDescription.Value = "Stage3", "white", IIF(Sum(Fields!DaysOpen.Value) < 5 ,"lime", IIF(Sum(Fields!DaysOpen.Value) < 10, "yellow" ,"red"))))