# KQL Max query search

**URL:** <https://discuss.elastic.co/t/kql-max-query-search/277061>\
**Category:** Kibana\
**Tags:** kql-kibana-query-language\
**Created:** [June 25, 2021, 1:00pm UTC](https://discuss.elastic.co/t/kql-max-query-search/277061 "2021-06-25T13:00:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fredrick.bb](https://avatars.discourse-cdn.com/v4/letter/f/7bcc69/32.png) [@fredrick.bb](https://discuss.elastic.co/u/fredrick.bb)\
**Post date:** [June 25, 2021, 1:00pm UTC](https://discuss.elastic.co/t/kql-max-query-search/277061/1 "2021-06-25T13:00:26Z")

</div>

Hello,

I need to figure out a KQL query to pick a max value. My data is like below  
Doc1 =\> AppName: "A" , Revision : 1 then other keys  
Doc2 =\> AppName: "A" , Revision : 2  
\*  
\*  
Docn =\> AppName: "A" , Revision : n.

Revision is integer

Here Revision will grow. I need to pick only the max Revision doc using a KQL query (Result should be one record that should have the max Revision number only). I need to use That value in Visualization. Thanks.

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [June 25, 2021, 3:21pm UTC](https://discuss.elastic.co/t/kql-max-query-search/277061/2 "2021-06-25T15:21:08Z")

</div>

[KQL is not the right tool to accomplish this task](https://www.elastic.co/guide/en/kibana/current/kuery-query.html). However, you might be able to accomplish this by using the `Max` aggregation.

---

<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:** [July 23, 2021, 3:22pm UTC](https://discuss.elastic.co/t/kql-max-query-search/277061/3 "2021-07-23T15:22:04Z")

</div>

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