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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
awitt
Helper III
Helper III

DATEDIFF Meausre Question

Looking to find the time difference betwee certain items within an order. My data set has a different line for each status of each item of each order. What i am looking to do is create a measeure that calculates the time between certain statuses within each of these unique order / item types. In this case, the time betwee the "confirmed" status and the "allocated" status.

 

I'm sure its a DATEDIFF function but i am having trouble with the filter context. 

 

Capture.PNG

 

 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @awitt 

1.create two tables based on your table

table 1

status_1 = VALUES(Sheet2[status])
Change [status] in this table to [status_1]
 
table2
status_2 = VALUES(Sheet2[status])
Change [status] in this table to [status_2]
 
Add [status_1] and [status_2] in two slicers
Note: don't create any relationships among these two tables with your main table, just leave them alone
 
2. create measures in your main table
selected1 = SELECTEDVALUE(status_1[status_1])

selected2 = SELECTEDVALUE(status_2[status_2])

date1 = CALCULATE(MAX(Sheet2[date]),FILTER(ALLEXCEPT(Sheet2,Sheet2[order number],Sheet2[item]),Sheet2[status]=[selected1]))

date2 = CALCULATE(MAX(Sheet2[date]),FILTER(ALLEXCEPT(Sheet2,Sheet2[order number],Sheet2[item]),Sheet2[status]=[selected2]))

diff = DATEDIFF([date1],[date2],HOUR)

final = IF([date2]=BLANK(),"N/A",[diff]/24)
5.png

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hi @awitt 

1.create two tables based on your table

table 1

status_1 = VALUES(Sheet2[status])
Change [status] in this table to [status_1]
 
table2
status_2 = VALUES(Sheet2[status])
Change [status] in this table to [status_2]
 
Add [status_1] and [status_2] in two slicers
Note: don't create any relationships among these two tables with your main table, just leave them alone
 
2. create measures in your main table
selected1 = SELECTEDVALUE(status_1[status_1])

selected2 = SELECTEDVALUE(status_2[status_2])

date1 = CALCULATE(MAX(Sheet2[date]),FILTER(ALLEXCEPT(Sheet2,Sheet2[order number],Sheet2[item]),Sheet2[status]=[selected1]))

date2 = CALCULATE(MAX(Sheet2[date]),FILTER(ALLEXCEPT(Sheet2,Sheet2[order number],Sheet2[item]),Sheet2[status]=[selected2]))

diff = DATEDIFF([date1],[date2],HOUR)

final = IF([date2]=BLANK(),"N/A",[diff]/24)
5.png

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.