Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
I am trying to figure out how to get the difference between two dates based on the event.
I have event IDs as follows:
1=Created
2=Activated
3=Respond
4=Resolve
5=Closed
I need to get the days between created (ID1) to either the resolve time (ID4) or if not resolved, the days open as of today's date.
Sample from Current Table:
| item_id | Event_ID | Event_Name | date_hour_local |
| 368901 | 1 | Created | 1/5/2024 |
| 368901 | 2 | Activated | 1/9/2024 |
| 368901 | 3 | Responded | 1/9/2024 |
| 368901 | 4 | Resolved | 1/9/2024 |
| 368902 | 1 | Created | 1/5/2024 |
| 368902 | 2 | Activated | 1/9/2024 |
| 368902 | 3 | Responded | 1/9/2024 |
| 368902 | 4 | Resolved | 1/9/2024 |
| 368903 | 1 | Created | 1/5/2024 |
| 368903 | 2 | Activated | 1/9/2024 |
| 368903 | 3 | Responded | 1/9/2024 |
| 368909 | 1 | Created | 1/3/2024 |
| 368909 | 2 | Activated | 1/9/2024 |
| 368909 | 3 | Responded | 1/9/2024 |
| 368910 | 1 | Created | 1/9/2024 |
| 368910 | 2 | Activated | 1/9/2024 |
| 368910 | 3 | Responded | 1/9/2024 |
| 368910 | 4 | Resolved | 1/9/2024 |
| 368911 | 1 | Created | 1/9/2024 |
| 368911 | 2 | Activated | 1/9/2024 |
| 368911 | 3 | Responded | 1/9/2024 |
| 368912 | 1 | Created | 1/9/2024 |
| 368912 | 2 | Activated | 1/9/2024 |
| 368912 | 3 | Responded | 1/9/2024 |
| 368913 | 1 | Created | 1/9/2024 |
| 368913 | 2 | Activated | 1/9/2024 |
| 368913 | 3 | Responded | 1/9/2024 |
| 368913 | 4 | Resolved | 1/9/2024 |
This DAX gets me close, but I just need the actual days open, so that I can use it in other parts of the design (ie Avg Days Open).
Solved! Go to Solution.
HI @madbaird,
You can try to use the following measure formasi lot get the difference between two event names if helps:
formula =
VAR created =
CALCULATE (
MIN ( 'Table'[date_hour_local] ),
FILTER ( ALLSELECTED ( 'Table' ), [Event_Name] = "Created" ),
VALUES ( 'Table'[item_id] )
)
VAR resolved =
CALCULATE (
MAX ( 'Table'[date_hour_local] ),
FILTER ( ALLSELECTED ( 'Table' ), [Event_Name] = "Resolved" ),
VALUES ( 'Table'[item_id] )
)
VAR lastest =
CALCULATE (
MAX ( 'Table'[date_hour_local] ),
ALLSELECTED ( 'Table' ),
VALUES ( 'Table'[item_id] )
)
VAR eventList =
CALCULATETABLE (
VALUES ( 'Table'[Event_Name] ),
ALLSELECTED ( 'Table' ),
VALUES ( 'Table'[item_id] )
)
RETURN
IF (
"Resolved" IN eventList,
DATEDIFF ( created, resolved, DAY ),
DATEDIFF ( created, lastest, DAY )
)
Regards,
Xiaoxin Sheng
HI @madbaird,
You can try to use the following measure formasi lot get the difference between two event names if helps:
formula =
VAR created =
CALCULATE (
MIN ( 'Table'[date_hour_local] ),
FILTER ( ALLSELECTED ( 'Table' ), [Event_Name] = "Created" ),
VALUES ( 'Table'[item_id] )
)
VAR resolved =
CALCULATE (
MAX ( 'Table'[date_hour_local] ),
FILTER ( ALLSELECTED ( 'Table' ), [Event_Name] = "Resolved" ),
VALUES ( 'Table'[item_id] )
)
VAR lastest =
CALCULATE (
MAX ( 'Table'[date_hour_local] ),
ALLSELECTED ( 'Table' ),
VALUES ( 'Table'[item_id] )
)
VAR eventList =
CALCULATETABLE (
VALUES ( 'Table'[Event_Name] ),
ALLSELECTED ( 'Table' ),
VALUES ( 'Table'[item_id] )
)
RETURN
IF (
"Resolved" IN eventList,
DATEDIFF ( created, resolved, DAY ),
DATEDIFF ( created, lastest, DAY )
)
Regards,
Xiaoxin Sheng
Thank you, that seems to work as needed.
@madbaird , Try new column or measure
New column =
datediff([date_hour_local],coalease( maxx(filter(Table,[item_id] = earlier([item_id]) && [Event_ID] = earlier([Event_ID])-1), [date_hour_local]),[date_hour_local]), DAY)
New Measure =
AverageX( Table, if([Event_ID] >1, datediff([date_hour_local],coalease( maxx(filter(Table,[item_id] = earlier([item_id]) && [Event_ID] = earlier([Event_ID])-1), [date_hour_local]),[date_hour_local]), DAY)))
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!
Check out the July 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 29 | |
| 23 | |
| 23 | |
| 22 | |
| 14 |
| User | Count |
|---|---|
| 48 | |
| 33 | |
| 20 | |
| 18 | |
| 16 |