'Dax query to get number of bussiness days (Excluding saturdays and sundays in a week)
For example if we have slicer with the date range from 1/1/2022 to 31/01/2022 , need to get the result of 21(working days)
Solution 1:[1]
Assuming you have a Date table, you could use this DAX measure:
Working Days =
CALCULATE(
COUNTROWS('Date Table'),
FILTER('Date Table',
Not WEEKDAY('Date Table'[Date],2) in {6,7}
)
)
The '2' in the WEEKDAY function indicates that the week should start with Monday as 1 and, therefore Saturday = 6 and Sunday = 7. We are then filtering the Date Table for any dates that are not Saturday or Sunday.
Solution 2:[2]
count working days =
CALCULATE (
COUNTROWS ( 'Dim table' ),
FILTER (
'Dim table',
'Dim table'[Date].[Day] <= DAY ( TODAY () )
&& 'Dim table'[Date].[MonthNo] = MONTH ( TODAY () )
&& 'Dim table'[Weekday] <= 5
)
)
Recall that 'Dim table' is where the date column sits
All the best
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | user15697117 |
Solution 2 | AKP |