Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DAX logic behind working days per month

Hi Experts,

I'm trying replicate the below, i have already went through many discussion topics but couldn't figure out a way to do this. Any Dax help is appreciated.   

I have created a date table and already found what are work days excluding all holidays. The goal is to calculate a KPI for each month by working days.

Thanks

 

image_thumb_31657773.png

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

using this DAX statement to create a simplified Calendar table:

Calendar = 
var datestart = DATE(2001 , 1 , 1)
var dateend = DATE(2004 , 12 , 31)
return
ADDCOLUMNS(
    CALENDAR(datestart , dateend)
    , "Year" , FORMAT(''[Date] , "YYYY")
    , "Month" , RIGHT("0" & FORMAT(''[Date] , "MM") , 2) & " - " & FORMAT(''[Date] , "MMM")
    , "is Workday" , IF(WEEKDAY(''[Date] , 2) <= 5 , 1 , 0)
)

As you can see the column [is workday] returns 1 if the weekday is from Monday to Friday otherwise 0 (you might consider to use BLANK() instead). The calculation for the calculated column [is workday] might be more complex if one has to consider other holidays (here I'm just considering the weekend), but the concept remains the the same: return 1 if it's a workday otherwise 0 or BLANK().

In addition to this I also create a simple measure like so:

No of Workdays = SUM('Calendar'[is Workday])

This allows to create a table like this, be aware that I'm just considering the weekend, for this reason the values vary:

image.png

Hopefully this provides some additional insights how to tackle your challenge.

 

Regards,

Tom

 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

3 REPLIES 3
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

Have you solved your problem with the suggestion of TomMartens ?

If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

If you still need help, please share your desired output.

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
TomMartens
Super User
Super User

Hey,

 

using this DAX statement to create a simplified Calendar table:

Calendar = 
var datestart = DATE(2001 , 1 , 1)
var dateend = DATE(2004 , 12 , 31)
return
ADDCOLUMNS(
    CALENDAR(datestart , dateend)
    , "Year" , FORMAT(''[Date] , "YYYY")
    , "Month" , RIGHT("0" & FORMAT(''[Date] , "MM") , 2) & " - " & FORMAT(''[Date] , "MMM")
    , "is Workday" , IF(WEEKDAY(''[Date] , 2) <= 5 , 1 , 0)
)

As you can see the column [is workday] returns 1 if the weekday is from Monday to Friday otherwise 0 (you might consider to use BLANK() instead). The calculation for the calculated column [is workday] might be more complex if one has to consider other holidays (here I'm just considering the weekend), but the concept remains the the same: return 1 if it's a workday otherwise 0 or BLANK().

In addition to this I also create a simple measure like so:

No of Workdays = SUM('Calendar'[is Workday])

This allows to create a table like this, be aware that I'm just considering the weekend, for this reason the values vary:

image.png

Hopefully this provides some additional insights how to tackle your challenge.

 

Regards,

Tom

 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.