I wanted to create the buckets for the total sales on the basis of the calculated value form metric aggs in lens
i have total field in doc
so if use agg of avg in lens then i want to create the range built on top of the return value this way i will have the avg_bucket of the range of total
and second the count of the customer fall in that avg_range bucket.
i think you have missed the point here i know there custom ranges and interval i wanted to utilize the resutlt of the metric aggs not the field directly.
Yes, here is the output i am looking for i know by transform its achieveable. but i want if its possible via TSVB/Lens
Suppose we have a field called total and customerId, and each customer has multiple orders in the index.
We need a monthly-wise visualization like this:
Average Monthly Sales Bucket Range
Bucket Name
# of Customers
$0 - $10
41
$11 - $20
Now, we will create a table visualization using Lens / TSVB
In the metric aggregations, I will add the avg(total) and unique_count(customerId). Now, I want to create a range bucket from the returned value of this avg(total) metric. I don’t want to create the range on the total field that already exists. Instead, I want to utilize the avg(total).
Ok, I think I've got it.
Interval buckets cannot be computed on top of aggs, so this won't be possible with regular Lens.
What you could do instead is use an ES|QL table visualization with a query like this:
FROM index
| stats t = avg(total) by customer_id
| stats c = COUNT_DISTINCT(customer_id) by rangeFrom = (v / 500)::integer
| sort rangeFrom
| eval range = concat(
to_String(rangeFrom * 500),
"-",
to_string((rangeFrom + 1) * 500)
)
| rename c as `# of Customers`, range as Bucket
| keep Bucket, `# of Customers`
I've built something along the lines with bytes and agent in place of total and customer_id but the final result was this:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.