Scripted field Avg

Hi,

I'd like to calculate a scripted field that makes me do this :

Count(nb_request)/UniqueCount(nb_request)

But i have no idea of how the language paineless works.

Thanks

Hi @Shyrine
I'm not sure you can create a scripted field that use aggregation like counts in it. Scripted fields are meant to be to add a new field on each single document based on a script that can at least involve calculation over other fields on the same document.

If you need to do that kind of operation, the only way is to create a visualization in TSVB where you can create two aggregregations (count of nb_request) and (unique count of bnb_request) and use a bucket script to compute the ratio.

1 Like

Hi @markov00

Thank you for your respond. However, I can't find the unique count in the aggregations in TSVB :roll_eyes:

Actually what I'm trying to do is this :

I want to compare the correlation between 3 values, the pink and yellow ones have the same "scale" but the green one needs to be reduced in order to compare it with the two others, so i had this idea of calculating its average...

You can probably use Cardinality on TSVB that will give you the unique count per bucket of a specific field

I found how to do it, I had just to add an Average Bucket Aggregation. :wink:

1 Like

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