Forum Discussion
Subtract the current value from the previous value?
- 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])
Hi,
This calculated column works
Data[Value]-LOOKUPVALUE(Data[Value],Data[Timestamp],CALCULATE(MIN(Data[Timestamp]),FILTER(Data,Data[Timestamp]>EARLIER(Data[Timestamp]))))
Hope this helps.
- M-M-P6 years ago
Helper 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_Mathur6 years ago
Super 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 ago
Helper III
Ashish_Mathur
Thanks a lot it works :)
- eleanoracook3 years agoNew Member
Hello,
I'm looking for help with a similar query where I want to subtract from a value three hours previous to the current row or 37 rows earlier rather than just the previous value. I'm very new to PowerBI so any help would be appreciated. Also for others reading the previous solution with as little knowledge as me, you need to change 'data' to your table name for it to work.
Thanks,
Eleanor
- Ashish_Mathur3 years ago
Super User
Hi,
Share some data to work with in a format (that can be pasted in an MS Excel file) and show the expected result.