Forum Discussion
return text based off calender date
Anonymous, further to my first reply, I have created a solution which takes working days into account.
Create a Date dimension table which has a WorkingDays column as an integer. For working days set this to 1, for non-working days set it to 0. In my example I used this data for October:
Date WorkingDays
| 01-Oct-23 | 0 |
| 02-Oct-23 | 1 |
| 03-Oct-23 | 1 |
| 04-Oct-23 | 1 |
| 05-Oct-23 | 1 |
| 06-Oct-23 | 1 |
| 07-Oct-23 | 0 |
| 08-Oct-23 | 0 |
| 09-Oct-23 | 1 |
| 10-Oct-23 | 1 |
| 11-Oct-23 | 1 |
| 12-Oct-23 | 1 |
| 13-Oct-23 | 1 |
| 14-Oct-23 | 0 |
| 15-Oct-23 | 0 |
| 16-Oct-23 | 1 |
| 17-Oct-23 | 1 |
| 18-Oct-23 | 1 |
| 19-Oct-23 | 1 |
| 20-Oct-23 | 1 |
| 21-Oct-23 | 0 |
| 22-Oct-23 | 0 |
| 23-Oct-23 | 1 |
| 24-Oct-23 | 1 |
| 25-Oct-23 | 1 |
| 26-Oct-23 | 1 |
| 27-Oct-23 | 1 |
| 28-Oct-23 | 0 |
| 29-Oct-23 | 0 |
| 30-Oct-23 | 1 |
| 31-Oct-23 | 1 |
Then in your data table, create a Calculated Column called WorkingDaysTillDueDate with this DAX expression:
WorkingDaysTillDueDate =
VAR duedate = YourTable[DueDate]
VAR today = TODAY()
RETURN
SWITCH(TRUE(),
duedate = today, 0,
duedate < today,
CALCULATE(
0 - SUM(dimDate[WorkingDays]),
dimDate[Date] >= duedate,
dimDate[Date] < today
),
duedate > today,
CALCULATE(
SUM(dimDate[WorkingDays]),
dimDate[Date] > today,
dimDate[Date] <= duedate
)
)
Now create another Calculated Column called DueStatus with this DAX expression:
DueStatus =
VAR days = YourTable[WorkingDaysTillDueDate]
RETURN
SWITCH(TRUE(),
days < 0, "Past Due",
days = 0, "Due Today",
days <= 2, "Due in Two Days",
"On Track"
)
When I run this today (25 Oct 2023) it gives me the following results for dates from 23 Oct to 30 Oct. And whenever you refresh the report, it will recalculate both Calculated Columns based on the current today's date.
You will need to maintain the dimDate table by populating it with any future dates and what the WorkingDays field should be for each.
Hopefully this helps.
Thank you very much for your help!! I have been able to create the calculation in excel to produce the correct Date Status. I have a report in Power Bi that I have recently created that is linked to a SP site and updates automatically. My next goal is to figure out how to add this new calculation / rows to the current report so that I can have the details linked. I am viewing videos online to learn how to do this (very new to Power BI). Fingers crossed I can update this soon. 🙂 Again, your help is very much appreciated.