Forum Discussion
M-M-P
6 years agoHelper III
Subtract 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])
M-M-P
6 years agoHelper III
Hi AlB Ashish_Mathur
Thank you very much for your response.
Your solutions works. But unfortunately only if I filter my data hard in the Querie editor.
Unfortunately, I have simplified my example table too much.
I do not have unique Timestamps because there are several units in the same table that have values logged at the same time. See a more correct example below:
Next time I will remember to include all the important parameters :)
Ashish_Mathur
6 years agoSuper User
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])
- M-M-P6 years agoHelper III
Ashish_Mathur
Thanks a lot it works :)- Ashish_Mathur6 years agoSuper User
You are welcome.
- Anonymous5 years agoNot applicable
Hi
I tried to use this calculation but got an error and that it expect the token Literal. Do you know why? The collum UnitID is changed with Device in my case, otherwise it's the same with value and timestamp