# KQL to filter for documents where a field exists and its value is less than a fixed number?

**URL:** https://discuss.elastic.co/t/kql-to-filter-for-documents-where-a-field-exists-and-its-value-is-less-than-a-fixed-number/262385
**Category:** Kibana
**Tags:** kql-kibana-query-language
**Created:** [January 27, 2021, 3:22pm UTC](https://discuss.elastic.co/t/kql-to-filter-for-documents-where-a-field-exists-and-its-value-is-less-than-a-fixed-number/262385 "2021-01-27T15:22:28Z")
**Posts on this page:** 2
**Page:** 2

<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: [February 5, 2021, 9:45pm UTC](https://discuss.elastic.co/t/kql-to-filter-for-documents-where-a-field-exists-and-its-value-is-less-than-a-fixed-number/262385/21 "2021-02-05T21:45:16Z")

</div>

It does seem like you're running into some of the limitations of the built-in visualizations that we offer. I've been working on both clarifying the existing limitations and making Lens into a tool that will eventually let you work around all of these limitations. For now, here is what I can tell you:

- We do offer a tool that doesn't have any of these limits, and it's [Vega](https://www.elastic.co/guide/en/kibana/master/vega.html). The Vega integration lets you build any Elasticsearch query and then apply post-processing in Javascript.
- In the long term, we will want to support [post-aggregation filtering of numbers](https://github.com/elastic/kibana/issues/86190) in Lens. This will work for any chart type. It's a common request for reasons just like the case you're seeing. I'm focused on post-aggregation filtering because none of our built-in visualizaiton
- Yes, the "top hit" aggregation is the same as "Last value". We have named it "Last value" because that's what users want.
- For now, you can use the conditional coloring workaround that you've already identified

---

<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 5, 2021, 9:45pm UTC](https://discuss.elastic.co/t/kql-to-filter-for-documents-where-a-field-exists-and-its-value-is-less-than-a-fixed-number/262385/22 "2021-03-05T21:45:51Z")

</div>

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

[Previous page](https://discuss.elastic.co/t/kql-to-filter-for-documents-where-a-field-exists-and-its-value-is-less-than-a-fixed-number/262385.md?page=1)
