Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Here is a sample of what my data looks like in Power BI. I need to create a new column that subtracts the date from the previous row, and I need to do this for thousands of IDs. How can I accomplish this?
First Create a Date Lookup Column and then create difference:
Dax for those two columns looks as below:
Date Lookup = LOOKUPVALUE('Dates Difference'[Dates],'Dates Difference'[Index],'Dates Difference'[Index]-1)Dates Diff = DATEDIFF('Dates Difference'[Date Lookup],'Dates Difference'[Dates],DAY)
Result sample looks as below:
If this post helps, then please consider accepting it as the solution to help other members find it more quickly. Thank You!!
@Anonymous See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])
  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.