# Histogram query over calculated field

**URL:** <https://discuss.elastic.co/t/histogram-query-over-calculated-field/353586>\
**Category:** Elasticsearch\
**Created:** [February 19, 2024, 12:22pm UTC](https://discuss.elastic.co/t/histogram-query-over-calculated-field/353586 "2024-02-19T12:22:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marinavictoria](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marinavictoria/32/131181_2.png) [@marinavictoria](https://discuss.elastic.co/u/marinavictoria)\
**Post date:** [February 19, 2024, 12:22pm UTC](https://discuss.elastic.co/t/histogram-query-over-calculated-field/353586/1 "2024-02-19T12:22:42Z")

</div>

My case is the following:  
doc1:  
event.type (keyword): a  
doc2:  
event.type: aa  
doc3:  
event.type: aa  
doc4:  
event.type: aaaa

I want to create a query that gives me in the Y axis the count of event.type and in the X axis the length of event.type.  
For the given example it would be:  
X axis ---------------------------- Y axis  
event\_type\_length: 1 event\_type\_count: 1  
event\_type\_length: 2 event\_type\_count: 2  
event\_type\_length: 3 event\_type\_count: 0  
event\_type\_length: 4 event\_type\_count: 1

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 18, 2024, 12:23pm UTC](https://discuss.elastic.co/t/histogram-query-over-calculated-field/353586/2 "2024-03-18T12:23:14Z")

</div>

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