Forum Discussion
return text based off calender date
Anonymous, this is a fairly standard problem. The way to solve it would be to create a Date dimension in your Power BI report. The Date dimension can have a column (e.g. IsWorkingDay) that indicates is a day is a working day or not. How you populate that column will depend on the needs of your solution. Having a Date dimension in place will make it easier to do many other time-based calculations.
Once you have created a Date dimension, you can then add a Calculated Column to your source data to work out what the DueStatus for each row is. The logic in this calculation will use today's date, the DueDate, and the Date dimension's IsWorkingDay flag to produce the Past Due, Due Today, Due in Two Days, On Track, or whichever other statuses are needed.
A basic demonstration of the Calculated Column, without using a Date dimension, is shown below.
DueStatus =
VAR daysdiff = DATEDIFF(TODAY(), YourTable[DueDate], DAY)
RETURN
SWITCH(TRUE(),
daysdiff < 0, "Past Due",
daysdiff = 0, "Due Today",
daysdiff <= 2, "Due in Two Days",
"On Track"
)
I am using this test data for YourTable:
| DueDate |
| 23 Oct 2023 |
| 24 Oct 2023 |
| 25 Oct 2023 |
| 26 Oct 2023 |
| 27 Oct 2023 |
| 28 Oct 2023 |
| 29 Oct 2023 |
| 30 Oct 2023 |
And this is the output:
Is this the sort of thing you are looking for?