# Kibana check if field is equal to 1 for every document during the selected time period

**URL:** https://discuss.elastic.co/t/kibana-check-if-field-is-equal-to-1-for-every-document-during-the-selected-time-period/241754
**Category:** Kibana
**Created:** [July 18, 2020, 5:25pm UTC](https://discuss.elastic.co/t/kibana-check-if-field-is-equal-to-1-for-every-document-during-the-selected-time-period/241754 "2020-07-18T17:25:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![haythem](https://avatars.discourse-cdn.com/v4/letter/h/45deac/32.png) [@haythem](https://discuss.elastic.co/u/haythem)
#### Post date: [July 18, 2020, 5:25pm UTC](https://discuss.elastic.co/t/kibana-check-if-field-is-equal-to-1-for-every-document-during-the-selected-time-period/241754/1 "2020-07-18T17:25:26Z")

</div>

Hi guys , i'm working on a project where i need to check absence and presence of employees , my index has 5 fields(MAT,NAME,DATE,PRESENCE(1or 0),ABSENCE(1 or 0)) it contains the data of the presence and absence of employees everyday , so my goal is to show in a metric visualization if a person is always present during the period selected in the time filter , i managed to make a unique count based on name feld and filter on presence eq 1 and absence eq 0 but it gives all the possible data and i need to check if his present the whole time .  
any idea what should i do ?  
any suggestion would be appreciated because i'm stuck here  
thanks in advance.

ELK 7.4.0

---

<div class="post-metadata">

### Author: ![Marta\_Bondyra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_bondyra/32/102122_2.png) [@Marta\_Bondyra](https://discuss.elastic.co/u/Marta_Bondyra)
#### Post date: [August 11, 2020, 6:26pm UTC](https://discuss.elastic.co/t/kibana-check-if-field-is-equal-to-1-for-every-document-during-the-selected-time-period/241754/2 "2020-08-11T18:26:50Z")

</div>

Hi @haythem,

you can achieve it in TSVB with a bit of workaround. In 'Panel options' tab, set up interval on your index pattern for `1d`. Then, in data tab, configure following metrics:

- Min of PRESENCE
- Overall Min of Presence - if the employee was present all the time, it will return 1. If they were absent, it will return 0.
- group it by Terms, by the field name.

Here's the configured data tab:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/1/51c01031dfa0a43c58b4553161ae153082983350.png)

Hope it helps!  
Marta

---

<div class="post-metadata">

### Author: ![haythem](https://avatars.discourse-cdn.com/v4/letter/h/45deac/32.png) [@haythem](https://discuss.elastic.co/u/haythem)
#### Post date: [August 12, 2020, 8:33am UTC](https://discuss.elastic.co/t/kibana-check-if-field-is-equal-to-1-for-every-document-during-the-selected-time-period/241754/3 "2020-08-12T08:33:18Z")

</div>

@Marta_Bondyra thank you so much , it works 😃

---

<div class="post-metadata">

### Author: ![haythem](https://avatars.discourse-cdn.com/v4/letter/h/45deac/32.png) [@haythem](https://discuss.elastic.co/u/haythem)
#### Post date: [August 12, 2020, 8:58am UTC](https://discuss.elastic.co/t/kibana-check-if-field-is-equal-to-1-for-every-document-during-the-selected-time-period/241754/4 "2020-08-12T08:58:53Z")

</div>

@Marta_Bondyra i have another question , is it possible to count all the absent or present employees in TSVB ?

---

<div class="post-metadata">

### Author: ![Marta\_Bondyra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_bondyra/32/102122_2.png) [@Marta\_Bondyra](https://discuss.elastic.co/u/Marta_Bondyra)
#### Post date: [August 12, 2020, 9:36am UTC](https://discuss.elastic.co/t/kibana-check-if-field-is-equal-to-1-for-every-document-during-the-selected-time-period/241754/5 "2020-08-12T09:36:16Z")

</div>

Glad it helped!  
@haythem do you mean count all present employees day by day? Or all the employees that were present in the selected period without single absence?

For day by day, the solution would be to selected interval 1d just like above and then create two filtered count metrics:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/7/a7058caf9da484766bd4a0995111f92491b8fedc.png)

For the selected period of time, it looks more complicated and I am not sure if we can achieve it with TSVB - we need to calculate overall min for each employee separately and after the breakdown count the '1's. Let me know if day by day is enough. Otherwise I think Vega is the way to go 🙂

---

<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: [September 9, 2020, 9:36am UTC](https://discuss.elastic.co/t/kibana-check-if-field-is-equal-to-1-for-every-document-during-the-selected-time-period/241754/6 "2020-09-09T09:36:42Z")

</div>

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