# Max between two fields in last X days Kibana(lens)

**URL:** <https://discuss.elastic.co/t/max-between-two-fields-in-last-x-days-kibana-lens/294765>\
**Category:** Kibana\
**Created:** [January 19, 2022, 5:20am UTC](https://discuss.elastic.co/t/max-between-two-fields-in-last-x-days-kibana-lens/294765 "2022-01-19T05:20:10Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [January 19, 2022, 2:59pm UTC](https://discuss.elastic.co/t/max-between-two-fields-in-last-x-days-kibana-lens/294765/5 "2022-01-19T14:59:16Z")

</div>

Hi @dash5000

welcome to the Kibana community.

Another possible approach would be to have a "creative" usage of the Formula feature in Lens, as I describe in [this post](https://discuss.elastic.co/t/dec-4th-2021-en-advanced-trick-and-tips-in-lens/289935#formula-comparisons-6). In your case the `metric(fieldA)` would be `max(fieldA)`, and same apply for `metric(fieldB) => max(fieldB)`.  
Combine this formula with a date histogram should work as you describe.

---

_[View the full topic](https://discuss.elastic.co/t/max-between-two-fields-in-last-x-days-kibana-lens/294765)._
