cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Preeti123
Frequent Visitor

Power BI Calculate Working Days For Every Month Dynamically

Hi Community Members,

 

Since I am new to Power BI, I don't know much about it, though I am learning. I have a simple requirement where I need to use Power BI DAX to display the current working day number out of the overall working day number and that should appear dynamically every month.

For example, 2020 April month has a total of 22 working days. And suppose today is the 20th working day out of 22days. So in Power BI Report, I need to display it as 20 of 22 days. Furthermore, I need to display "As of April 28, 2020" above it (Using DAX only and this one should likewise alter dynamically). Refer to the screenshot link below:

Power-BI-Calculate-Working-Days-Dynamically 

 

Can anyone please help me out to achieve this? Thanks in Advance!!

1 REPLY 1
PaulOlding
Super User
Super User

Hi @Preeti123 

You could use the NETWORKDAYS function to do this.

Work Day = 
VAR _Today = TODAY()
VAR _WorkDaysInMonth = NETWORKDAYS (EOMONTH (_Today, -1) + 1, EOMONTH (_Today, 0))
VAR _WorkDayToday = NETWORKDAYS (EOMONTH (_Today, -1) + 1, _Today)
VAR _Result = _WorkDayToday & " of " & _WorkDaysInMonth & " days"
RETURN
    _Result
As Of Date = 
VAR _Today = TODAY()
VAR _Result = "As of " & FORMAT(_Today, "mmmm d, yyyy")
RETURN
    _Result

Note this uses the TODAY() function to get today's date.  One extension yuou might want to do is base it on the last time the data was refreshed, rather than assume it's updated successfully today.  You can use M function DateTime.LocalNow() in a new query in Power Query to get that.

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Top Solution Authors
Top Kudoed Authors