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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
kasiaw29
Resolver II
Resolver II

Simple way to calculate working days between two dates.

Hi all, 

 

I've search all round this forum to find a simple solution to figure out number of working days between two dates. i.e. excluding weekend. I actually had to use two existing posts and some existing skills to make it a bit easier to understand. 

All dates in my example are hypothetical....Here it goes:

 

Start with creating new table that will act as a calendar 

Next use this in formula bar of newly created table (you're giving it a name and it's first column

MyCalendar =
CALENDAR(MIN('Activivty History'[Latest Baseline Dispatch Date].[Date]),MAX('Sub Project w Activities'[ACTUAL_START].[Date]))
 
Explanation: CALENDAR funtion returns a table that contains a set of dates, it names your column simply as Date, whereas the usage of MIN and MAX indicates your date ranges of your date set. So I'm using MIN date found in Latest Baseline Dispatch Date column and MAX date found in Actual Start column.  You should see something like this so far:
 
2020-06-03_15-48-22.jpg
 
 
 
 
 
 
 
 
 
Next we need to figure out week days within date range we just created. Create new column and copy and paste this:
Week Day = WEEKDAY(MyCalendar[Date].[Date],2)
As per documentation this function "Returns a number from 1 to 7 identifying the day of the week of a date". Syntax for this is:
WEEKDAY(<date>, <return_type>). There are three different return types, read here more about it. I have used 2 in above code as it indicated week beggining on Monday (1) and ending on Sunday (7).
You should now have something like this: 

2020-06-03_15-53-34.jpg

You can see your 6 & 7 which is your Saturday and Sunday (feel free to check the calendar like I did to see if this was right

Next what you want to do is create a simple IF statement that determines if it's a working day or not, so use this:

Working Day = IF(DimDate[Week Day] in {1,2,3,4,5},"True","False")
This IF statement simply goes and checks what the week day is and if it falls within 1-5 range returns True otherwise it returns False. 
 
Now return to your table where you want to figure out your working days between two dates and do this: 
 
WorkingDays Early or Late =
COUNTROWS(
FILTER(MyCalendar,
AND(
AND(
MyCalendar[Date].[Date] >='Activivty History'[Latest Baseline Dispatch Date].[Date],
MyCalendar[Date].[Date] <=RELATED('Sub Project w Activities'[ACTUAL_START].[Date])),

MyCalendar[Working Day])))
 
You're counting number of rows within filtered MyCalendar table you have created where your date range is (in my example) between Latest Baseline Dispatch Date and Actual Start and it only counts the ones that are True  in Working Day calendar. 
 
Hope this helped someone out there! 
 
Thanks
Kasia 
1 REPLY 1
Anonymous
Not applicable

Hi,
I believe that this article from SQL BI is just what you're looking for!

https://www.sqlbi.com/articles/counting-working-days-in-dax/

 

Hope this helps!

Kim

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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