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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Scottnap
Frequent Visitor

Trying to do DATEDIFF across rows in a table using measure

I have a table that gives me the change history for work items.  The date/time of each change is stored in the ChangeDate field.
I'm trying to calculate how ong it takes an item to transition from when it is changedTo "EXTERNAL RCA IN PROGRESS" to "EXTERNAL RCA UNDER REVIEW"

TransitionHistory.png

The dates I need to diff are in the same column, however the dates I need to calcuatle are in different rows.  I have 3 different measures.

First measure - get the In_Progress_Start date

 

In_Progress_Start = CALCULATE(MIN(DIRCA_Transitions[DIRCA.changelog.histories.created]),DIRCA_Transitions[DIRCA.changelog.histories.items.toString]="EXTERNAL RCA IN PROGRESS")

 

 Second Measure get the In_progress_Finish date

 

In_Progress_Finish = CALCULATE(MIN(DIRCA_Transitions[DIRCA.changelog.histories.created]),DIRCA_Transitions[DIRCA.changelog.histories.items.toString]="EXTERNAL RCA UNDER REVIEW")

 

Finally, calculate the difference between the two dates.

 

Time_In_Progress = 
VAR DIRCA_FILTER = VALUES(DIRCA_Transitions[DIRCA.key])
RETURN
SUMX(KEEPFILTERS(DIRCA_FILTER),DATEDIFF(DIRCA_Transitions[In_Progress_Start],DIRCA_Transitions[In_Progress_Finish],DAY))

 

The first two measures work fine, they accurately give me the start and finish times for the phase I want to measure.  However the third measure yields nothing.  Can someone please help me figure out what I'm doing wrong here?  Seems like it should be simple but I've been banging my head on this for hours now!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Scottnap , Try like

SUMX(VALUES(DIRCA_Transitions[DIRCA.key]),DATEDIFF([In_Progress_Start],[In_Progress_Finish],DAY))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Scottnap , Try like

SUMX(VALUES(DIRCA_Transitions[DIRCA.key]),DATEDIFF([In_Progress_Start],[In_Progress_Finish],DAY))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you!  That did the trick!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.