The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
I have a measure which counts the number of days between two dates using the DATEDIFF funtion and that's fine. However, as this is a business related measure, i need to exclude weekends.
So Friday to Monday should be calculated as 1 day.
Any ideas if this is possible?
Thanks
Create a proper Dates table and then you'll be able to do this:
[# Working Days] = CALCULATE( COUNTROWS( Dates ), KEEPFILTERS( Dates[Working Day] = TRUE() ) )
Best
Darek
Thanks for the reply. I now have this calculation in my date table, but how do i use this to measure working days from a date in my other data table? Sorry if i have misunderstoof Darek.
Very easy in fact...
If you have 2 dates D1 and D2, then the number of working days between them is this:
var __dateStart = D1 -- your start date var _dateEnd = D2 -- your end date var __workingDays = calculate( [# Working Days], Dates[Date] >= D1, Dates[Date] <= D2 ALL( Dates ) ) return __workingDays
Best
Darek
You need the equivalent to Excel's NETWORKDAYS
https://www.sqlbi.com/articles/counting-working-days-in-dax/
User | Count |
---|---|
15 | |
13 | |
9 | |
6 | |
6 |
User | Count |
---|---|
27 | |
18 | |
13 | |
9 | |
5 |