# Kibana :: Count if the id not exist for the event

**URL:** https://discuss.elastic.co/t/kibana-count-if-the-id-not-exist-for-the-event/238609
**Category:** Kibana
**Created:** [June 25, 2020, 6:48am UTC](https://discuss.elastic.co/t/kibana-count-if-the-id-not-exist-for-the-event/238609 "2020-06-25T06:48:47Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Jai1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jai1/32/47451_2.png) [@Jai1](https://discuss.elastic.co/u/Jai1)
#### Post date: [June 25, 2020, 6:48am UTC](https://discuss.elastic.co/t/kibana-count-if-the-id-not-exist-for-the-event/238609/1 "2020-06-25T06:48:47Z")

</div>

hi,

I have a data like this:

```auto
id : 1,event: event1
id: 2,event:event1
id: 2,event:event2
id:3,event:event1

```

Need to count the ids having only event1 not in event2  
expecting is 2 count

---

<div class="post-metadata">

### Author: ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)
#### Post date: [June 25, 2020, 8:50am UTC](https://discuss.elastic.co/t/kibana-count-if-the-id-not-exist-for-the-event/238609/2 "2020-06-25T08:50:36Z")

</div>

You can do this by using a metric visualization with a "Unique count" on the id field. Then, to exclude the "event2" ids, add a filter below the search bar in the top - you can exclude the value `event2` from the event field. If you save the visualization and put in on a dashboard, this filter will be saved along with the visualization and applied as well.

---

<div class="post-metadata">

### Author: ![Jai1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jai1/32/47451_2.png) [@Jai1](https://discuss.elastic.co/u/Jai1)
#### Post date: [June 25, 2020, 9:54am UTC](https://discuss.elastic.co/t/kibana-count-if-the-id-not-exist-for-the-event/238609/3 "2020-06-25T09:54:21Z")

</div>

This is not worked as still id counts

---

<div class="post-metadata">

### Author: ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)
#### Post date: [June 25, 2020, 10:28am UTC](https://discuss.elastic.co/t/kibana-count-if-the-id-not-exist-for-the-event/238609/4 "2020-06-25T10:28:10Z")

</div>

It's helpful if you could provide more context. Could you make a screenshot of your configuration?

---

<div class="post-metadata">

### Author: ![Jai1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jai1/32/47451_2.png) [@Jai1](https://discuss.elastic.co/u/Jai1)
#### Post date: [June 25, 2020, 10:40am UTC](https://discuss.elastic.co/t/kibana-count-if-the-id-not-exist-for-the-event/238609/5 "2020-06-25T10:40:49Z")

</div>

sure... will provide. before that would like to say... that leadId contains other events too...

---

<div class="post-metadata">

### Author: ![Jai1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jai1/32/47451_2.png) [@Jai1](https://discuss.elastic.co/u/Jai1)
#### Post date: [June 25, 2020, 10:58am UTC](https://discuss.elastic.co/t/kibana-count-if-the-id-not-exist-for-the-event/238609/6 "2020-06-25T10:58:39Z")

</div>

image will be posted

---

<div class="post-metadata">

### Author: ![Jai1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jai1/32/47451_2.png) [@Jai1](https://discuss.elastic.co/u/Jai1)
#### Post date: [June 25, 2020, 11:01am UTC](https://discuss.elastic.co/t/kibana-count-if-the-id-not-exist-for-the-event/238609/7 "2020-06-25T11:01:38Z")

</div>

posted:

---

<div class="post-metadata">

### Author: ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)
#### Post date: [June 26, 2020, 8:01am UTC](https://discuss.elastic.co/t/kibana-count-if-the-id-not-exist-for-the-event/238609/8 "2020-06-26T08:01:09Z")

</div>

I'm still not sure what exactly you want to achieve - it would really help if you would provide more context, not just little snippets.

An important note about how Kibana works:  
In Visualizations you define filters (on the top) and aggregations (in the side bar). The filters are applied first, that means all documents in your index are filtered down according to the filters. After that, the aggregations are applied to the remaining documents. The result is shown as a chart.

If this is about filtering out documents based on the fact whether other documents exist, this is not possible using your raw documents. You might want to get familiar with transforms: [https://www.elastic.co/guide/en/elasticsearch/reference/current/transforms.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/transforms.html) Those offer a way to transform your documents by grouping them in some way.

---

<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 24, 2020, 8:01am UTC](https://discuss.elastic.co/t/kibana-count-if-the-id-not-exist-for-the-event/238609/9 "2020-07-24T08:01:15Z")

</div>

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