# Counting the duplicates and non-duplicates of a count aggregation (revisited)

**URL:** <https://discuss.elastic.co/t/counting-the-duplicates-and-non-duplicates-of-a-count-aggregation-revisited/247856>\
**Category:** Kibana\
**Created:** [September 8, 2020, 9:30am UTC](https://discuss.elastic.co/t/counting-the-duplicates-and-non-duplicates-of-a-count-aggregation-revisited/247856 "2020-09-08T09:30:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![benji87](https://avatars.discourse-cdn.com/v4/letter/b/7993a0/32.png) [@benji87](https://discuss.elastic.co/u/benji87)\
**Post date:** [September 8, 2020, 9:30am UTC](https://discuss.elastic.co/t/counting-the-duplicates-and-non-duplicates-of-a-count-aggregation-revisited/247856/1 "2020-09-08T09:30:48Z")

</div>

Hello all,

My recently submitted topic was closed due to inactivity, but I just wondered if anyone else had any thoughts on it?

You can find the original post here - [Counting the duplicates and non-duplicates of a count aggregation](https://discuss.elastic.co/t/counting-the-duplicates-and-non-duplicates-of-a-count-aggregation/243916)

Essentially, I'm trying to count the number of 'single instance' documents as one value, and the number of 'duplicate instance' documents as another value. Essentially a count of a count I believe.

Thanks in advance 🙂

---

<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:** [September 10, 2020, 8:08pm UTC](https://discuss.elastic.co/t/counting-the-duplicates-and-non-duplicates-of-a-count-aggregation-revisited/247856/2 "2020-09-10T20:08:17Z")

</div>

This is a use case for [data transformations](https://www.elastic.co/guide/en/elasticsearch/reference/current/transforms.html) in ES. You can create a transformed index that uses the following settings:

- Group by Terms of the ID
- Cardinality aggs

The result should be documents containing something like `{ key: 'A', count: 3 }` which you can then filter using the standard ES filters.

---

<div class="post-metadata">

**Author:** ![benji87](https://avatars.discourse-cdn.com/v4/letter/b/7993a0/32.png) [@benji87](https://discuss.elastic.co/u/benji87)\
**Post date:** [October 7, 2020, 8:38am UTC](https://discuss.elastic.co/t/counting-the-duplicates-and-non-duplicates-of-a-count-aggregation-revisited/247856/3 "2020-10-07T08:38:51Z")

</div>

Hi Wylie Conlon,

Thank you for this! I've been sidetracked recently but I'm going to look into your suggestion in the next few days. I'll report back here on any progress.

Thanks

---

<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:** [November 4, 2020, 8:38am UTC](https://discuss.elastic.co/t/counting-the-duplicates-and-non-duplicates-of-a-count-aggregation-revisited/247856/4 "2020-11-04T08:38:51Z")

</div>

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