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
barryjarvis
New Member

Number of working days between slicer dates

I have a table of data with a 'CreatedOn' date column, I currently use a slicer to filter the report by those dates.

I'd like to get the number of working days between those two dates.

 

I've found some examples of this question previously, but they seem to have two columns of dates (i.e. start date | end date) so don't really match what I'm trying to do.

 

Can somebody point me in the right direction for this please?

1 REPLY 1
Anonymous
Not applicable

Hi @barryjarvis,

You could look into using the min and max functions with the datediff function. 

Measure = DATEDIFF(min(Query1[Date]), max(Query1[Date]), DAY)
 
If you would like to calculate working days between the 2 dates, you will need to have a column in your table indiciatnig whether it is a working or non working day. 
 
You can then calculate the number of non-working days between your selection and subtract it from the days between the start and end date in your selection to get the number of working days between the range. 
 
Im new to powerbi myself and this may not be the best approach but it does do the trick. Below is the dax code for the measure
 
Measure =
var weekends = COUNTROWS(FILTER(Query1, Query1[isWorkingDay] = False()))
var totaldays = DATEDIFF(min(Query1[Date]), max(Query1[Date]), DAY)

return totaldays - weekends

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.