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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
PPStar
Helper V
Helper V

Calculate Duration for open and closed tickets

Hello. 

 

I have a ticket table, which lists all the tickets we have, with columns such as closed date, opened date, state

 

I need to be able to calcuate the duration of each ticket as a colum in my table. 

 

At the moment, i have closed at - opened at which gives me the duration... But this does not account for tickets that are not closed. 

I need to have one column which does the following : If the ticket is closed, do closed at - opened at else if it the ticket is open, do TodaysDate - opened at. 

 

 

 

1 ACCEPTED SOLUTION
johnbasha33
Super User
Super User

@PPStar try below 
Duration =
IF (
NOT ISBLANK('Ticket'[Closed Date]),
'Ticket'[Closed Date] - 'Ticket'[Opened Date],
TODAY() - 'Ticket'[Opened Date]
)

Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi  @PPStar ,

 

Have you solved your problem? If it's solved, you can mark the correct answer, if not, provide more detailed information and we can help you better!

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

johnbasha33
Super User
Super User

@PPStar try below 
Duration =
IF (
NOT ISBLANK('Ticket'[Closed Date]),
'Ticket'[Closed Date] - 'Ticket'[Opened Date],
TODAY() - 'Ticket'[Opened Date]
)

Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!

amitchandak
Super User
Super User

@PPStar , I think it better to have table calculating Active tickets, as given file, for Active/Current employees

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
PPStar
Helper V
Helper V

If ([States] = closed then [closed_at]-[opened_at] else DateTime.LocalNow - [opened_at])

 

I have that above formula, but i keep getting a syntax error. 

 

note, closed at and opened at are just date column (not time). Could that be the issue

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors