Calculate difference between two consecutive rows

(Nabha Shirkul) #1

We need to calculate diff between two readings in two consecutive records.

Rec 1 = time1, meter reading 1

Rec 2 = time 2, meter reading 2

Consumption between time 2 – time 1

= meter reading 2 – meter reading 1

(Mark Harwood) #2

See this discussion

(Nabha Shirkul) #3

Hi Mark, I didn't find it suitable.
My requirement is exactly same as hsiuming from How to calculate delta value
That I want to perform operations on same column. I tried script but it didn't work to achieve the goal. What I want is the delta value in the same column.
Script function seems only can calculate the value between two column.

(Mark Harwood) #4

Got it. Sorry, I assumed you had to worry about multiple meters and join on their ID.

I’d be tempted to perform this computation “upstream” of elasticsearch. If you have multiple shards or time based indices the records will be scattered around a network by default, making it harder to perform the logic.

(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.