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.
Hi Community,
I have a calculation that works out actual hours in a shift minus any unavailabilty, but require it to exclude any that overlap and not be calculated twice. There are 2 tables; 1 to show all employees and the shift they are rostered for each day. The 2nd table is a list of all unavailability recorded. Each unavailabilty has been split onto individual days.
Emp | Date | Shift Start | Shift End | Shift Hours |
1 | 24/06/2024 | 08:00 | 14:00 | 6 |
1 | 25/06/2025 | - | - | 0 |
Emp | Date | Unavailabilty Type | Unavailabilty Start | Unavailabilty End |
1 | 24/06/2024 | Annual Leave | 08:00 | 14:00 |
1 | 24/06/2024 | Sickness | 00:00 | 23:59 |
1 | 25/06/2024 | Sickness | 00:00 | 23:59 |
Added a column to the shift table to work out unavailable hours, it calculates -12 for the 24th giving an actual hours total of -6
Hi @PKCRonny
Ensure there's a relationship between your two tables based on to accurately correlate shifts with unavailability periods.
Use DAX to calculate the overlapping hours between the shift hours and the unavailability periods.
This involves creating a new measure that compares the start and end times of shifts and unavailability periods to determine the overlap duration.
Adjust your calculation for actual hours to subtract only the unique unavailability hours from the total shift hours.
For example:
Actual Hours =
SUMX(
ShiftsTable,
[Shift Hours] -
MAXX(
FILTER(
UnavailabilityTable,
UnavailabilityTable[EmpDate] = ShiftsTable[EmpDate]
),
[Unavailability Duration]
)
)
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hi, thanks for that.
Wondered if I could add another scenario, as I did not include some of the harder entries by the staff.
There is occasions where both unavailability have to be included, so would be looking to see if any of the availability overlapped. Adding different entries to the original table for new scenario.
Emp | Date | Unavailabilty Type | Unavailabilty Start | Unavailabilty End |
1 | 24/06/2024 | Meeting | 10:00 | 11:00 |
1 | 24/06/2024 | Private Appointment | 13:00 | 15:00 |
for this scenario, both unavailability would be included.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
26 | |
10 | |
10 | |
9 | |
6 |