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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Date difference in same column for different stage

Hi,

  I need a Calculated column for Date difference of same date based on different stages and ID.The stage will start at any level, for initial stage date difference should be 0 for each ID. The Final column value should as in Date Difference

Capture.PNG

2 ACCEPTED SOLUTIONS
PattemManohar
Community Champion
Community Champion

@Anonymous Please try this as a "New Column"

 

DateDiff = 
VAR _PrevDate = LOOKUPVALUE(Test48CummDateDiff[Date],Test48CummDateDiff[ID],Test48CummDateDiff[ID],Test48CummDateDiff[Stage],Test48CummDateDiff[Stage]-1) 
VAR _PrevDateClean = IF(_PrevDate=BLANK(),Test48CummDateDiff[Date],_PrevDate)
RETURN DATEDIFF(_PrevDateClean,Test48CummDateDiff[Date],DAY)

image.png

 





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

Proud to be a PBI Community Champion




View solution in original post

@Anonymous 🙂 It's working fine, As per the screenshot - Your data contains 23-Aug-2017 for Stage 3, ID 421 (Row 3) that's why you are seeing huge date difference. But where as your initial sample data contains 23-Aug-2018.





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

Proud to be a PBI Community Champion




View solution in original post

4 REPLIES 4
PattemManohar
Community Champion
Community Champion

@Anonymous Please try this as a "New Column"

 

DateDiff = 
VAR _PrevDate = LOOKUPVALUE(Test48CummDateDiff[Date],Test48CummDateDiff[ID],Test48CummDateDiff[ID],Test48CummDateDiff[Stage],Test48CummDateDiff[Stage]-1) 
VAR _PrevDateClean = IF(_PrevDate=BLANK(),Test48CummDateDiff[Date],_PrevDate)
RETURN DATEDIFF(_PrevDateClean,Test48CummDateDiff[Date],DAY)

image.png

 





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

Proud to be a PBI Community Champion




Anonymous
Not applicable

@PattemManohar Thanks for the effort. But as output am getting different values as below. I need a date difference of previous stages for each ID

Capture.PNG

 

@Anonymous 🙂 It's working fine, As per the screenshot - Your data contains 23-Aug-2017 for Stage 3, ID 421 (Row 3) that's why you are seeing huge date difference. But where as your initial sample data contains 23-Aug-2018.





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

Proud to be a PBI Community Champion




Anonymous
Not applicable

@PattemManohar Thanks:-)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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