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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
bob57
Helper IV
Helper IV

Calculate difference of value in current row from value in previous row.

Hello. This seems simple enough but has offered me a bit of a challenge. I am seeking a DAX measure to solve this problem. I am also curious as to how a calculated column could do the same.

Eaxample data table:

DateCumulative Sold
1/1/20203
1/2/20205
1/3/202010
1/4/202014
1/5/202015
1/6/202020

 

I need to create a table visualization that displays the two columns from the data table (easy enough) and develop a DAX measure for the third column as shown below.

DateCumulative SoldDaily Num Sold
1/1/202033
1/2/202052
1/3/2020105
1/4/2020144
1/5/2020151
1/6/2020205

 

Thank you for your time and effort.

Bob

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

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/3395...

 

In your case:

Daily Num Sold Measure =
  VAR __Current = MAX('Table'[Cumulative Sold])
  VAR __Date = MAX('Table'[Date])
  VAR __PreviousDate = MAXX(FILTER('Table',[Date] < __Date),[Date])
  VAR __Previous = MAXX(FILTER('Table',[Date] = __PreviousDate),[Cumulative Sold])
RETURN
  __Current - __Previous


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

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/3395...

 

In your case:

Daily Num Sold Measure =
  VAR __Current = MAX('Table'[Cumulative Sold])
  VAR __Date = MAX('Table'[Date])
  VAR __PreviousDate = MAXX(FILTER('Table',[Date] < __Date),[Date])
  VAR __Previous = MAXX(FILTER('Table',[Date] = __PreviousDate),[Cumulative Sold])
RETURN
  __Current - __Previous


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
bob57
Helper IV
Helper IV

My apologies for the very poor colimn alignment.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.