Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi!
In power Query, I need to extract number of working days for a month. But the table I have has the dates.
| Dates |
1/2/2022 |
| 1/3/2022 |
| 1/9/2022 |
| 1/19/2022 |
| 1/25/2022 |
Since there are 20 weekdays for January 2022, my table should look like this.
| Dates | Weekdays |
1/2/2022 | 20 |
| 1/3/2022 | 20 |
| 1/9/2022 | 20 |
| 1/19/2022 | 20 |
| 1/25/2022 | 20 |
I do not mind additional columns. I tried adding two columns and writing a fuction.
Two columns:
StartD = Date.StartOfMonth([DATE])
EndD = Date.EndOfMonth([DATE])
Function:
= (StartDate as date, EndDate as date) as number =>
let
ListDates = List.Dates(StartDate,Number.From(EndDate-StartDate),#duration(1,0,0,0)),
RemoveWeekends = List.Select(ListDates,each Date.DayOfWeek(_,Day.Monday) <5 ),
CountDays = List.Count(RemoveWeekends)
in
CountDays
But values for weekdays appears to be wrong for some months.
I tried adding as:
RemoveWeekends = List.Select(ListDates,each Date.DayOfWeek(_,Day.Monday)+1 <=5 )
But results are still wrong.
Please help 😞
Solved! Go to Solution.
You likely need to add 1 to your count in List.Dates.
Number.From(EndDate-StartDate) + 1
Pat
You likely need to add 1 to your count in List.Dates.
Number.From(EndDate-StartDate) + 1
Pat
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 6 | |
| 4 | |
| 3 |
| User | Count |
|---|---|
| 19 | |
| 14 | |
| 12 | |
| 10 | |
| 8 |