Forum Discussion
How to Calculate Days Past Due
- 4 years ago
Hi Gasdetect40
I'm going to suggest an answer using DAX, not Power Query. Create a calculated column to calculate the number of days overdue. And then a second column to group them.
DaysOverdue = DATEDIFF( [ExpectedReturnDate], TODAY(), DAY ) DaysOverdueGrouping = SWITCH( TRUE(), Table[DaysOverdue] <= 2, "2 Days", AND( Table[DaysOverdue] > 2, Table[DaysOverdue] <= 7 ), "7 Days", AND( Table[DaysOverdue] > 7, Table[DaysOverdue] <= 15 ), "15 Days", "15+ Days" )I'm not sure of your table and field names so check those. And check that the logic for each grouping is correct.
Hope this helps!
Hi Gasdetect40
I'm going to suggest an answer using DAX, not Power Query. Create a calculated column to calculate the number of days overdue. And then a second column to group them.
DaysOverdue =
DATEDIFF(
[ExpectedReturnDate],
TODAY(),
DAY
)
DaysOverdueGrouping =
SWITCH(
TRUE(),
Table[DaysOverdue] <= 2, "2 Days",
AND(
Table[DaysOverdue] > 2,
Table[DaysOverdue] <= 7
), "7 Days",
AND(
Table[DaysOverdue] > 7,
Table[DaysOverdue] <= 15
), "15 Days",
"15+ Days"
)
I'm not sure of your table and field names so check those. And check that the logic for each grouping is correct.
Hope this helps!
Gasdetect40 going to amend my response. I'm used to working in Analysis Services, which doesn't allow grouping/binning the same way Power BI Desktop does. You don't really have to create the second column if you want to use the grouping feature in desktop.