Forum Discussion
Convert cumulative data to non-comulative data
I have real time energy consumption data with a timestamp streaming from a websocket.
16/7/2020 00:00.00 6
16/7/2020 00:00.00 14
16/7/2020 00:00.00 17
16/7/2020 00:00.00 34
I would like to get Powerbi to show the non-cumulative values as show below in the lat column
16/7/2020 00:00.00 6 6
16/7/2020 00:00.00 14 8
16/7/2020 00:00.00 17 3
16/7/2020 00:00.00 34 17
Any help would be appreciated.
15 Replies
- mahoneypatMicrosoft Employee
Assuming the time component of your DateTime values are not all zeros, you can use an expression like this to get your result in a measure. Use the measure in a table visual with your DateTime column. Let me know if you need the column version instead.
Actual Consumption = VAR __thisvalue = MIN ( Table[EnergyConsumed] ) VAR __thisdatetime = MIN ( Table[DateTime] ) VAR __prevdatetime = CALCULATE ( MAX ( Table[DateTime] ), ALL ( Table[DateTime] ), Table[DateTime] < __thisdatetime ) VAR __prevvalue = CALCULATE ( MIN ( Table[EnergyConsumed] ), ALL ( Table[DateTime] ), Table[DateTime] = __prevdatetime ) RETURN __thisvalue - __prevvalueIf this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
- flintstoneHelper II
Thanks, Pat. I keyed in the code but it ran into some errors as highlighted in red
- flintstoneHelper II
- Ashish_MathurSuper User
Hi,
This calculated column formula works
Column = Casting[Incoming 33kv]-LOOKUPVALUE(Casting[Incoming 33kv],Casting[DateTimeStamp],CALCULATE(MAX(Casting[DateTimeStamp]),FILTER(Casting,Casting[DateTimeStamp]<EARLIER(Casting[DateTimeStamp]))))Hope this helps.
- flintstoneHelper II
Regretably both set of codes in Power bi did not work. I have now enclosed the larger data in the link
- flintstoneHelper II
Hi! Any ideas/solutions so far?
- Ashish_MathurSuper User
Hi,
What problem did you face with my formula?