Does kibana support weighted average calculations

Hi, Does kibana support weighted average if yes, can someone shed some light on it ? or is there any way to write a query for same?

Thank you..

What are you weighting the values by? Something in each document or some fixed values? Off-hand, this seems like a candidate for using Scripted Fields in Kibana.

This blog has some good examples; https://www.elastic.co/blog/using-painless-kibana-scripted-fields

Regards,
Lee

Hi Lee, thanks for your response can i do below calculations ?

Data

image
if a person smoke more than three times habit_risk_score should double

final_risk per subject = habit_risk_score * weight

can you guide me on how to store new field "final_risk" in existing index and visualize it in Kibana

thank you.... :slight_smile:

Here's a good blog about scripted field in Kibana; https://www.elastic.co/blog/using-painless-kibana-scripted-fields

But note that scripted fields are calculated per document. So you wouldn't be able to use the total count of multiple docs for a subject to influence the weight.
Maybe you can calculate a risk score for each doc and then add them up?

Thanks Lee , i am trying this, can we use scripted field as input for other scripted field.

example :
First use regex to create a scripted field habits 'smoke'
Then create another scripted field score '2' value based on previous scripted field through if construct ?

I don't think you can use one scripted field inside another scripted field.

thank you ....will calculate it again when required... :slight_smile:

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