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
gkakun
Helper III
Helper III

Event duration

Hi everyone, 

 

I tried to find solution online, but nothing I found give me the exact result I need. 

 I have Escalation table, with lifecycle, when its opened, moved to other status like on hold, watch, open, etc (can have additional statuses in the future)

 

I have timestamp for each event and I need to create "Duration in days" like i created in excel in the table attached. 

 

gkakun_0-1672075695261.png

 

 

gkakun_1-1672075716111.png

 

 

Thank you all. Have merry christmas and happy new year! 

1 ACCEPTED SOLUTION
themistoklis
Community Champion
Community Champion

@gkakun 

 

Using Power Query sort the table data by Escalation ID and Date Time ASC

Then create an Index column  in Power Query (Add Column --> Index Column)

 

Finally create a new column with the following DAX formula:

Duration in Days = 
  VAR Previous = MAXX(FILTER(Sheet1,Sheet1[Escalation ID]= (Sheet1[Escalation ID]) && Sheet1[Index]-1 =EARLIER(Sheet1[Index])),Sheet1[Date Time])

RETURN
  DATEDIFF(Sheet1[Date Time],Previous,HOUR) /24

 

I have attached the PowerBI workspace

 

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Share data in a format that can be pasted in an MS Excel file.  Share data of atleast 2 Escalation ID's.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
ppm1
Solution Sage
Solution Sage

Please see this article that explains a great way to work with durations in DAX.

Calculate and Format Durations in DAX – Hoosier BI

 

Pat

Microsoft Employee
themistoklis
Community Champion
Community Champion

@gkakun 

 

Using Power Query sort the table data by Escalation ID and Date Time ASC

Then create an Index column  in Power Query (Add Column --> Index Column)

 

Finally create a new column with the following DAX formula:

Duration in Days = 
  VAR Previous = MAXX(FILTER(Sheet1,Sheet1[Escalation ID]= (Sheet1[Escalation ID]) && Sheet1[Index]-1 =EARLIER(Sheet1[Index])),Sheet1[Date Time])

RETURN
  DATEDIFF(Sheet1[Date Time],Previous,HOUR) /24

 

I have attached the PowerBI workspace

 

Its working. Thanks a lot! 

Idrissshatila
Super User
Super User

Hello,

 

You could use the datediff fucntion and specify the interval to day.

DATEDIFF(<Date1>, <Date2>, <Interval>)

 

like this DATEDIFF ( StartDate, EndDate, Day)

 

ypu can check this link for more info about datediff https://learn.microsoft.com/en-us/dax/datediff-function-dax

 

 

If I answered your question, please mark my post as solution so it would appeare to others, Appreciate your Kudo 👍

Follow me on Linkedin



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Hi, Thanks!  Yes, I familiar with this function and tried all kind of versions with it, but nothing worked as expcted so far 

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.

Top Solution Authors
Top Kudoed Authors