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
TatyDo
Helper III
Helper III

Calculate diff in an cumulative values

Hallo all,

I have this table as below, and I am looking for a way to calculate a new column. 

 

So here the values are accumulative for each ID, therefore I am looking for a way to calculate the difference between each value and the value before it for each ID.

I could use this formula, but it does not work to distinguish each ID that I have. 

 

Column =
VAR NextIndex = Wirkarbeit[Index] - 1
RETURN
Wirkarbeit[Value]
- CALCULATE (
VALUES ( Wirkarbeit[Value] ),
FILTER ( ALL ( Wirkarbeit), Wirkarbeit[Index] = NextIndex )
)
 
 
TatyDo_0-1619435911869.png

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@TatyDo , Try a new column like

 

new column =
var _max =maxx(filter(Table, [ID] = earlier([ID]) && [datetime] <earlier([Datetime])),[Datetime])
return
if(isblank(_max), [value] , [value] -maxx(filter(Table, [ID] = earlier([ID]) && [datetime] =_max),[value]))

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@TatyDo , Try a new column like

 

new column =
var _max =maxx(filter(Table, [ID] = earlier([ID]) && [datetime] <earlier([Datetime])),[Datetime])
return
if(isblank(_max), [value] , [value] -maxx(filter(Table, [ID] = earlier([ID]) && [datetime] =_max),[value]))

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.