Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Kitu11
Frequent Visitor

Calculate the time difference

Hello all,

I hope you're all doing well.

I want to determine the total number of hours between the instances when the status was "On Hold" and the subsequent status.

 

At this moment, I am using a calculated column 

Total onhold difference(Business hours) = 
Var start_ = 
CALCULATE(
    MAX('Case history'[Created Date]),
    'Case history'[New Value] = "On Hold" &&
    'Case history'[Field] = "Status"
)

Var end_ = 
CALCULATE(
    MAX('Case history'[Created Date]),
    'Case history'[Old Value] = "On Hold" &&
    'Case history'[New Value] <> "On Hold" &&
    'Case history'[Field] = "Status"
)

return 
SUMX(
    CALCULATETABLE(
        'Calendar table',
        DATESBETWEEN('Calendar table'[Date],start_,end_),
        'Calendar table'[weekday] = 1
    ),
    MAX(MIN('Calendar table'[end],end_)-MAX('Calendar table'[start],start_),0)*24)
This calculated column Only calculates the latest on hold time difference because of  Max Function,

As you can see in the photo below, the time which was marked in a black spot was excluded but I want to also include it in the calculation.
 
Kitu11_0-1691130784708.png

I have attached the link to the power bi file
https://drive.google.com/file/d/1wtJIpwRktMROzQPfL3HSoecDEXbDj2K2/view?usp=sharing 

 

Could you please help me here?

 

Thank you so much in advance

2 REPLIES 2
Kitu11
Frequent Visitor

Could  anyone please help me with this? Any help would be much appreciated:)

Kitu11
Frequent Visitor

 

Spoiler
 

Hello all,

it would be really helpful if you guys give me any suggestions on this topic 🙂
Thank you from the mountain 
Regards

Kate

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.