SSRS background color expression based by date value - date

Here is my issue, I have a table in SSRS that I've created that has a due date field (RegulatoryDateDecisionDue). Based on that date field, I need to change the colors of the rows if today's date is past the due date the field should be red. If the amount of hours are less than or equal to 72 hours from today's date till the due date (basically like a countdown till it's due), the rows should be orange, else rows should be white.
Here is the expression I wrote, but I am having an issue, I get error, and idea what I am doing wrong or if I should be doing this differently? Any and all help appreciated.
=IIF((now() > Fields!RegulatoryDateDecisionDue.Value), "Red", IIF(((DateDiff(DateInterval.Hour, Fields!RegulatoryDateDecisionDue.Value, Now()) <= "72"), "Orange", "White")))

Try:
=Switch(
DateDiff(DateInterval.Hour, Fields!RegulatoryDateDecisionDue.Value, Now())<=72,"Orange",
Fields!RegulatoryDateDecisionDue.Value<now(),"Red",
true,"White"
)
It is better use Switch for multiple conditions.
Let me know if this helps.

Some things to try :
Use a switch instead of iif to have a better reading
use "h" insted of DateInterval.Hour
write 72 instead of "72"

Related

How do I filter my data for the same time last year - Power Query

I'm making an excel file that will be used for a report on sickness absence.
We are looking at the last 100 days (which I've been able to do with a simple filter in my Applied Steps) and we want to compare to the same time last year plus 100 days before that date AND look at 50 days after that date.
How can I filter for this in Power Query? Or do I have to write a custom formula? (In which case, does anyone know what and where to write it)
Idea is to be able to run this report every day/week and give updates on how we're doing in the winter in comparison to last year.
Any help on this will be greatly appreciated, thank you in advance!
Use the drop down filter atop the date column ... Date filters ... between ... and enter some random set of dates like 1/30/2019 through 1/30/2020
That generates this code
= Table.SelectRows(#"Changed Type", each [date] >= #date(2019, 1, 30) and [date] <= #date(2020, 1, 30))
edit it for your desired date range which could be like this
= Table.SelectRows(#"Changed Type", each [date] >= Date.AddDays(targetdate, -465) and [date] <= Date.AddDays(targetdate, -315))
I assume -465 which is last year (365 days prior) plus 100 days back, and -315 which is -365+50
As for what to use instead of targetdate ... you didn't tell us .. perhaps hardcode a date #date(2019,10,31), use whatever you had in your original filter, or maybe the maximum of the current date column
List.Max(#"priorstepname"[date])

Using dateadd with specific conditions

So I have two different date fields in my report. One is command.install date and the other is command.mfgdate. My problem is for some records mfgdate is blank and others installdate is blank and sometimes both dates exist in a record. I’m trying to use a formula with dateadd to return a replacement date based on a predetermined number of years. What I would like to do is use a formula that would first use mfgdate then use installdate as a “safety net” if mfgdate happens to be blank. Is there anyway that this is possible?
If a date shows "blank" inside the report, it usually means the date is NULL.
Therefore, the following formula should give you the desired result:
If Not IsNull({command.mfgdate}) Then
{command.mfgdate}
Else If Not IsNull({command.installdate}) Then
{command.installdate}
Else
// backup-date if both dates are NULL
CDate(1900,1,1)

Tableau: Conditional Formatting Rows based on a data range

Any help you can provide would be appreciated. I can't find any tableau tutorials that deal with conditional formatting based on dates. Plenty of formatting based on cell values, but that doesn't help in this case.
I am trying to create a tableau report that shows the change records that are due within the below criteria and color code the rows accordingly.
The next seven days represented by "red"
The next 14 days represented by "yellow"
Greater than 14 days out represented by "green"
Everything else would have a white background
Something I did that sounds similar was around due dates:
Create a calculated field called "Due Date Traffic Lights" to work out your days amount. The below gives the date difference between the given date field and today:
DATEDIFF('day',MAX([Due Date]), MAX(TODAY()))
Create calculated field "if" function called "Due Date Range" to categrorise these results:
if [Due Date Traffic Lights] < -7 THEN "GREEN: Over One Week Left"
ELSEIF [Due Date Traffic Lights] > -7 AND [Due Date Traffic Lights] <0
THEN "ORANGE: Due in one Week"
ELSE "RED: Overdue"
END
So on your rows you can then drag the "Due Date Range" into your "Color Icon" and set the color for each of the 3.

Tableau (Data > X days)

I'm a novice to Tableau, not going to lie. But for the life of me I can't figure out how to pull data from a table that's greater than thirty days old.
Basically, I have a set of work orders, and I'm just trying to get the count of the total work orders that are open AND older than thirty days. How would I go about doing this? I feel like it's a lot simpler than I'm trying to make it out to be.
You will have to create a calculated field and filter on that.
right click on your date field choose Create/Calculated Field
Use this formula, with [Date] being your date field: TODAY() - [Date] or, more flexible DATEDIFF("day" , [Date], TODAY())
give it a name eg. datediff
drag and drop datediff to the filter shelf, choose "all values" and set the range, for you 0-30
That should do the trick.
You can use your date filed as a filter and choosing the relative filter format.

Number of days between past date and current date in Google spreadsheet

I want to calculate the number of days passed between past date and a current date. My past date is in the format dd/mm/yyyy format. I have used below mentioned formulas but giving the proper output.
=DAYS360(A2,TODAY())
=MINUS(D2,TODAY())
In the above formula A2 = 4/12/2012 (dd/mm/yyyy) and I am not sure whether TODAY returns in dd/mm/yyyy format or not. I have tried using 123 button on the tool bar, but no luck.
The following seemed to work well for me:
=DATEDIF(B2, Today(), "D")
DAYS360 does not calculate what you want, i.e. the number of days passed between the two dates – see the end of this post for details.
MINUS() should work fine, just not how you tried but the other way round:
=MINUS(TODAY(),D2)
You may also use simple subtraction (-):
=TODAY()-D2
I made an updated copy of #DrCord’s sample spreadsheet to illustrate this.
Are you SURE you want DAYS360? That is a specialized function used in the
financial sector to simplify calculations for bonds. It assumes a 360 day
year, with 12 months of 30 days each. If you really want actual days, you'll
lose 6 days each year.
[source]
Since this is the top Google answer for this, and it was way easier than I expected, here is the simple answer. Just subtract date1 from date2.
If this is your spreadsheet dates
A B
1 10/11/2017 12/1/2017
=(B1)-(A1)
results in 51, which is the number of days between a past date and a current date in Google spreadsheet
As long as it is a date format Google Sheets recognizes, you can directly subtract them and it will be correct.
To do it for a current date, just use the =TODAY() function.
=TODAY()-A1
While today works great, you can't use a date directly in the formula, you should referencing a cell that contains a date.
=(12/1/2017)-(10/1/2017) results in 0.0009915716411, not 61.
I used your idea, and found the difference and then just divided by 365 days. Worked a treat.
=MINUS(F2,TODAY())/365
Then I shifted my cell properties to not display decimals.
If you are using the two formulas at the same time, it will not work...
Here is a simple spreadsheet with it working:
https://docs.google.com/spreadsheet/ccc?key=0AiOy0YDBXjt4dDJSQWg1Qlp6TEw5SzNqZENGOWgwbGc
If you are still getting problems I would need to know what type of erroneous result you are getting.
Today() returns a numeric integer value: Returns the current computer system date. The value is updated when your document recalculates. TODAY is a function without arguments.
The following worked for me. Kindly note that TODAY() must NOT be the first argument in the function otherwise it will not work.
=DATEDIF( W2, TODAY(), "d")
Today() does return value in DATE format.
Select your "Days left field" and paste this formula in the field
=DAYS360(today(),C2)
Go to Format > Number > More formats >Custom number format and select the number with no decimal numbers.
I tested, it works, at least in new version of Sheets, March 2015.