Displaying difference of sum of two values


(Divyaharshan) #1

I have a dataset loaded in the below csv format

time, totalnumber, correctnumber, location

I need to do a query similar to below sql

select sum(totalnumber)- sum(correctnumber) group by time, location

Is this possible in elastic search kibana, I am currently have a scripted field Totalnumber-currentnumber and am currently displaying SUM of this in a line graph split by location and time.
But it would really help if I can display sum(totalnumber)- sum(correctnumber)


(Marius Dragomir) #2

Easiest way to do this would be in Timelion.

Just create a chart with this function:
.es(*,metric='sum:totalnumber').subtract(.es(*,metric='sum:correctnumber')


(Divyaharshan) #3

Is there a way to group this is timelion for me it would be like difference
at a particular time for a particular location.


#4

I would like to do this kind of thing but term by term, something like:

average(user.t2 - user.t1)
and not
average(user.t2) - average(user.t1)

is there a way to do it?


(Marius Dragomir) #5

Are user.t1 and user.t2 present in every document? If so, then average(user.t2 - user.t1) will be the same as average(user.t2) - average(user.t1)


(system) #6

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