Forum Discussion
M-M-P
Helper III
6 years agoSubtract the current value from the previous value?
Hello everyone I've been struggling with a calculated column. I have a table that looks like this: I'm trying to subtract the current value from the previous value so I get a new colum...
- 6 years ago
Hi,
Does this work?
Data[Value]-LOOKUPVALUE(Data[Value],Data[Timestamp],CALCULATE(MIN(Data[Timestamp]),FILTER(Data,Data[Timestamp]>EARLIER(Data[Timestamp])&&Data[UnitID]=EARLIER(Data[UnitID]))),Data[UnitID],Data[UnitID])
v-eachen-msft
Community Support
6 years agoHi M-M-P ,
You could create a rank column to use EARLIER() function.
rank = RANKX ( 'Table', 'Table'[Timestamp],, ASC, DENSE )
Then create your "New Column".
New Column =
VAR a =
CALCULATE (
FIRSTNONBLANK ( 'Table'[Value], 1 ),
FILTER ( 'Table', 'Table'[rank] = EARLIER ( 'Table'[rank] ) + 1 )
)
RETURN
'Table'[Value] - a