Forum Discussion
Calculate workdays between two dates, but have multiple dates columns
I'm tearing my hair out with this one and would appreciate the help!
I have tried various options with the CALENDAR and CALENDARAUTO function as well as trying to create the column within my main table and can't seem to make it work, all solutions searched seem to have the assumption there is only two date columns to work with so think this is my issue.
Basically, I have multiple columns e.g.
| Start | Assess | Prep | Submit | Issue | After |
| 1 January 2022 | 1 January 2022 | 2 January 2022 | 15 January 2022 | 20 January 2022 | 23 January 2022 |
| 12 September 2022 | 14 September 2022 | 19 September 2022 | 31 September 2022 | 1 October 2022 | 4 october 2022 |
I did a date diff calc to work out the days between each of these, but obviously, this would include weekends.
| Start | Assess | wdays between St+P | Prep | wdays between As+S | Submit | wdays between P+S | Issue | wdays between S+I | After | wdays between I+Af |
| 31 December 2021 | 3 January 2022 | 1 | 4 January 2022 | 1 | 15 January 2022 | 8 | 20 January 2022 | 4 | 24 January 2022 | 1 |
| 12 September 2022 | 14 September 2022 | 3 | 19 September 2022 | 4 | 30 September 2022 | 10 | 1 October 2022 | 1 | 4 october 2022 | 2 |
I want to exclude weekends and have the count only show weekdays (not fussed about holidays at the current moment, and can probably work that one out once I have done this bit).
I tried the following:
- Creating a calendar and referencing back to it
= (ADDCOLUMNS( CALENDARAUTO(), "Formatted Date", FORMAT([Date],"dd MMMM yyyy"))
WEEKDAY = WEEKDAY(DetermineDay[Formatted Date])
WORKDAY = IF(OR(DetermineDay[WeekDay]=1,DetermineDay[WeekDay]=7),0)
But then I got an error when trying to reference back to this table for the date differences
- Also this one
Workdays =
COUNTROWS (
FILTER (
ADDCOLUMNS (
CALENDAR ('Sheet1'[Start], 'Sheet1'[Assess]),
"Day of Week", WEEKDAY ( [Date], 2 )
),
[Day of Week] <> 6
&& [Day of Week] <> 7
))
But I'm getting start and end date cannot be blank error - I also tried following https://www.youtube.com/watch?v=zzSoA8RuJR8 but it doesn't seem to like working for me either
I'm really stuck, would appreciate any help here!
Thank you!
Anonymous , Have tried the new networkdays function? It has quite a few option inculding an option for holiday calendar
https://amitchandak.medium.com/power-bi-dax-function-networkdays-5c8e4aca38c
3 Replies
- amitchandakSuper User
Anonymous , Have tried the new networkdays function? It has quite a few option inculding an option for holiday calendar
https://amitchandak.medium.com/power-bi-dax-function-networkdays-5c8e4aca38c
- AnonymousNot applicable
Thanks amitchandak - I assume I need an updated version of PBi for this to work yes? Currently Networkdays is coming up grey for me.
- AnonymousNot applicable
Hi amitchandak Absolute lifesaver! This worked, I dodnt realise there was an update, makes life so much easier. Thank you!