# Count if field 1 bigger than field 2

**URL:** <https://discuss.elastic.co/t/count-if-field-1-bigger-than-field-2/232503>\
**Category:** Kibana\
**Created:** [May 13, 2020, 7:28pm UTC](https://discuss.elastic.co/t/count-if-field-1-bigger-than-field-2/232503 "2020-05-13T19:28:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjabrantes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjabrantes/32/78091_2.png) [@cjabrantes](https://discuss.elastic.co/u/cjabrantes)\
**Post date:** [May 13, 2020, 7:28pm UTC](https://discuss.elastic.co/t/count-if-field-1-bigger-than-field-2/232503/1 "2020-05-13T19:28:42Z")

</div>

Hi all,

Imaging that i have the data:  
time. Person. Hours. limit of hours  
datatime1 person1 5 6  
datatime1 person2 7 6  
datatime1 person3 5 6  
datatime2 person1 9 6  
datatime2 person2 5 6  
datatime2 person3 20 6

And i want to count how many people crossed the limit on the most recent update.  
I tried to use a filter Hours \> limit of hours in discover, but seems that it didn't work as nothing appeared no matter time range...  
Should this be possible? my idea was to use such a thing in Goal or metric of TSVB.

When searching in web i found answers like created a scripted field or a having that information in input like new field with True/False.

Thanks,

---

<div class="post-metadata">

**Author:** ![anjilinga](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anjilinga/32/86010_2.png) [@anjilinga](https://discuss.elastic.co/u/anjilinga)\
**Post date:** [May 13, 2020, 9:11pm UTC](https://discuss.elastic.co/t/count-if-field-1-bigger-than-field-2/232503/2 "2020-05-13T21:11:48Z")

</div>

one way is you can use scripted field in index pattern.

---

<div class="post-metadata">

**Author:** ![cjabrantes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjabrantes/32/78091_2.png) [@cjabrantes](https://discuss.elastic.co/u/cjabrantes)\
**Post date:** [May 14, 2020, 9:11am UTC](https://discuss.elastic.co/t/count-if-field-1-bigger-than-field-2/232503/3 "2020-05-14T09:11:09Z")

</div>

Yes, but do we really need it? can't filter field1 \> field2 in Kibana?

---

<div class="post-metadata">

**Author:** ![cjabrantes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjabrantes/32/78091_2.png) [@cjabrantes](https://discuss.elastic.co/u/cjabrantes)\
**Post date:** [May 21, 2020, 10:57am UTC](https://discuss.elastic.co/t/count-if-field-1-bigger-than-field-2/232503/4 "2020-05-21T10:57:28Z")

</div>

Hi i just created a new field in logstash, can be closed.

---

<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:** [June 18, 2020, 10:57am UTC](https://discuss.elastic.co/t/count-if-field-1-bigger-than-field-2/232503/5 "2020-06-18T10:57:40Z")

</div>

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