Forum Discussion
Workdays in current Month
There's a function called NETWORKDAYS.
These are the parameters NETWORKDAYS(<start_date>, <end_date>[, <weekend>, <holidays>]). By default it excludes weekends. You just need to do something like this:
NETWORKDAYS(<StartDateOfMonth>,<EndDateOfMonth>)
Thank you, but unfortunately NETWORKDAYS is not an option in my version of Power BI 😞
- pbiuseruk1 year ago
Resolver IV
Ahh, to be honest, I'd strongly recommend updating it or asking your admins to because that's crazy.
But if you can't then another way to do this (although I'm not the biggest fan of this), is to make a day column in Power Query (really simple to do - just select the date field in your calender table, then fo to add columns tab at the top, select the dates dropdown on the top right and then select Day).
^This will add a Day field to the calender table like Monday, Tuesday, etc..
Then in Power Query, make a conditional column and then say If Monday, then Weekday, If Tuesday, then Weekday, etc...
Then in your model, make sure that you do it in a way where you link the calendar table to any dates fields in other tables and then you'll be able to use that column as a filter in your pages.
Hope that makes sense. - 123abc1 year ago
Community Champion
o calculate the number of workdays (weekdays) in the current month in Power BI, you can use DAX to account for weekdays without needing the NETWORKDAYS function.
Here's a DAX formula that calculates the number of weekdays in the current month:
DAXCopy codeWorkdays_CurrentMonth = VAR StartOfMonth = DATE(YEAR(TODAY()), MONTH(TODAY()), 1) VAR EndOfMonth = EOMONTH(TODAY(), 0) VAR DaysList = GENERATESERIES(StartOfMonth, EndOfMonth, 1) RETURN COUNTX( FILTER( DaysList, WEEKDAY([Value], 2) <= 5 -- This filters out weekends (Saturday and Sunday) ), [Value] )Explanation:
- StartOfMonth calculates the first day of the current month.
- EndOfMonth uses EOMONTH to get the last day of the current month.
- GENERATESERIES creates a list of all dates between StartOfMonth and EndOfMonth.
- WEEKDAY([Value], 2) checks if the day is a weekday (Monday to Friday), where 2 means the week starts on Monday.
- FILTER is used to exclude weekends.
- Finally, COUNTX counts the number of weekdays.
This formula will return the number of workdays in the current month.