Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I'm trying to find the number of working hours between two dates. I have a start and end date. Right now, I'm finding the number of working days between the dates and then multiplying it by the hours in the work day, but this is resulting in some rounding error (i.e. 4.3 days is rounded to 4 days). Is there a way to get a fraction of a day or calculate the working hours outright?
Working Hours -- 1st Shift is Monday to Friday 8 hours/day
2nd Shift is Monday to Thursday 10 hours/day -- only certain entries have a second shift
Right now I'm finding the 1st shift working days and the 2nd shift working days separately and then adding them together.
I have some of the DAX used in calculated columns below for reference. Are there any suggestions?
1. Find the number of first shift working days for an entry. It's the same for second shift but <=4
Solved! Go to Solution.
Hi @hsparg008 ,
A new DAX used to return the number of workdays between date range. It always returns whole number.
NETWORKDAYS(<start_date>, <end_date>[, <weekend>, <holidays>])
NETWORKDAYS function (DAX) - DAX | Microsoft Docs
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @hsparg008 ,
A new DAX used to return the number of workdays between date range. It always returns whole number.
NETWORKDAYS(<start_date>, <end_date>[, <weekend>, <holidays>])
NETWORKDAYS function (DAX) - DAX | Microsoft Docs
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you turn a date/time into a number (say, you multiply it by 1.0), it'll give you a number. On such numbers you can carry out arithmetic to obtain durations in (fractional) days. Check this out:
EVALUATE
var dt = convert("2020-12-10 14:20:12", DATETIME)
return
{(1.0 * dt, dt)}
Run this in DAX Studio as is.
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
10 | |
6 |