Calculate Percentage in Kibana

Can we calculate percentage in kibana. I have two fields. Count and count difference. I want to aggregate based on dept and calculate (count difference/count) * 100 for the various dept buckets

Please help me

You could either reindex your data to already have this field or use scripted fields to achieve the same (but it will be way slower)

to do it with scripted fields:

  • go to management, index patterns, select your index pattern, select scripted fields, add a new one
  • in the script enter something like return 100 * doc['field1name'].value / doc['field2name'].value
  • give it a name and save it, now you can use this field as any other

some docs:

1 Like

Thanks I was able to use this. Can watcher be applied to this scripted field?

i think that should be possible, however not completely sure.

1 Like

I created a saved search and added a new scripted field %Count_Difference using Count_Diff and Count Field. Can that saved search be grouped by another field dept ?

1 Like

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