Scripted field. Calculating percentage


#1

Hello,

I want to as how to write script to calculate percentage. I want to calculate percentage of every industry in every state. Main problem is that I don't know how to write specific industry in specific state in script. I know it should look something like this ((specific industry in state) * 100) /doc['industry.count'].

Thank you in advance.


(Tim Sullivan) #2

Hi TSimkevicius,

You would need a field in your data for the (specific industry in state) in order to script a field like this.

If you don't have it, your best option to see the calculation in Kibana would be to run a calculation on the data in an ES query, and then index the result back into your data so you can work with it in Kibana.

If your data is time-based and seeing the data in a timeseries makes sense for your use case, you can maybe try Timelion which has an expression language that lets you do some calculations on data inside time buckets.


#3

Thank you for your answer. I will try run calculation in an ES query.


(system) #4

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