cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Smithy33
Regular Visitor

Ignoring Weekends

Hi - New PBI user here.....

Struggling with DAX code for a simple calculation to Count total days of the week (ignore Sat / Sun) 

Column for 'Days difference' between 2 dates, and for the days difference total to ignore saturday / sunday, returning values of 1 for days of the week and returning 0 for sat/sun entries?

 

Any assistance appreciated....

1 REPLY 1
Watsky
Super User
Super User

Hiya @Smithy33 ,

 

First welcome to the community!

 

Are you using a Date Table by any chance? If so in Power Query you could add a column to it by clicking on your data range field, going to Add Column at the top, click the Date section, hover your mouse over Day then select day of week. That will give you the numerical version of the weekday. If you are not using a Date Table then how are you determining the day of the week?

 

Watsky_0-1632261521723.png

I wasn't sure where you were pulling your date range from so for this example I used my date calendar and did the difference between the min and max of my calendar (9/21/2020 to 9/21/2021). Here's the formula I used:

 

Total Working Days = 
VAR MaxDate =
    MAX ( Calendar[Date Range] )
RETURN
    CALCULATE (
        COUNT ( Calendar[Date Range] ),
        DATEDIFF ( MaxDate, Calendar[Date Range], DAY ),
        AND ( Calendar[Day of Week] <> 0, Calendar[Day of Week] <> 6 )
    )

 

This resulted in a total of 261 working days.

 

Watsky_1-1632261912625.png


Did my answer(s) help you? Give it a kudos by clicking the Thumbs Up! ?
Did my post answer your question(s)? Mark my post as a solution. This will help others find the solution.


Did my answer(s) help you? Give it a kudos by clicking the Thumbs Up!
Did my post answer your question(s)? Mark my post as a solution. This will help others find the solution.

Proud to be a Super User!

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors