# Unique count per fieldA by FieldB and sum this total per fieldC + graphing

**URL:** <https://discuss.elastic.co/t/unique-count-per-fielda-by-fieldb-and-sum-this-total-per-fieldc-graphing/275359>\
**Category:** Kibana\
**Created:** [June 8, 2021, 11:57pm UTC](https://discuss.elastic.co/t/unique-count-per-fielda-by-fieldb-and-sum-this-total-per-fieldc-graphing/275359 "2021-06-08T23:57:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![KS\_123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ks_123/32/81648_2.png) [@KS\_123](https://discuss.elastic.co/u/KS_123)\
**Post date:** [June 8, 2021, 11:57pm UTC](https://discuss.elastic.co/t/unique-count-per-fielda-by-fieldb-and-sum-this-total-per-fieldc-graphing/275359/1 "2021-06-08T23:57:13Z")

</div>

I want to do a unique count per fieldA(serialNumber) by FieldB(CommandID) and sum this total per fieldC(farmID).  
Which I can do in Kibana, but then I want to be able to collapse the rows to just show the FieldC(farmID) value.

the below picture might illustrate it better.

I have got the value in kibana(using visualisations) as the pic shows.  
Any idea how to collapse the rows?  
Or How would I be able to plt this value 92, over time at a per farm level in kibana or grafana

kiban pic

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/2/e2b9a7c1621072f394b4b5ba8fc95721634d7d37.png)

grafana pic(noter value is 93 it should be 92)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/0/d0ccb23ae53c26e94ebf00a87e82028496d00d3f.png)

posted here also as is a kibana/grafana related topic.

> **[Unique count per fieldA by FieldB and sum this total per fieldC + graphing](https://community.grafana.com/t/unique-count-per-fielda-by-fieldb-and-sum-this-total-per-fieldc-graphing/48629)**
>
> I want to do a unique count per fieldA(serialNumber) by FieldB(CommandID) and sum this total per fieldC(farmID). Which I can do in Kibana, but then I want to be able to collapse the rows to just show the FieldC(farmID) value. the below picture...

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [June 9, 2021, 12:30am UTC](https://discuss.elastic.co/t/unique-count-per-fielda-by-fieldb-and-sum-this-total-per-fieldc-graphing/275359/2 "2021-06-09T00:30:45Z")

</div>

You could choose to split by table on the `farmID` field, rather than splitting by row. That would collapse the farm ID column by showing a separate table per farm ID.

The other option is to just make a separate data table visualization that splits the rows on the farmID only. You could create a dashboard that shows both tables on one screen.

---

<div class="post-metadata">

**Author:** ![KS\_123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ks_123/32/81648_2.png) [@KS\_123](https://discuss.elastic.co/u/KS_123)\
**Post date:** [June 9, 2021, 2:54am UTC](https://discuss.elastic.co/t/unique-count-per-fielda-by-fieldb-and-sum-this-total-per-fieldc-graphing/275359/3 "2021-06-09T02:54:32Z")

</div>

tks, have tried that but not sure I follow, as I have to count uniquely on ther serial number and then take that value per command id and add that up. that comes to 92. 93 is wrong as that includes a duplicates for serial number. I want farmId,92, without all the other noise, if that makes sense.

---

<div class="post-metadata">

**Author:** ![KS\_123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ks_123/32/81648_2.png) [@KS\_123](https://discuss.elastic.co/u/KS_123)\
**Post date:** [June 14, 2021, 9:02pm UTC](https://discuss.elastic.co/t/unique-count-per-fielda-by-fieldb-and-sum-this-total-per-fieldc-graphing/275359/4 "2021-06-14T21:02:04Z")

</div>

think I get that now. tks

But what I want is to collapse per farm like this, so that is 1 row per farm with its associated values.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/9/596996b90451e2286c165cb588b30eba1743048d.png)

---

<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 12, 2021, 9:02pm UTC](https://discuss.elastic.co/t/unique-count-per-fielda-by-fieldb-and-sum-this-total-per-fieldc-graphing/275359/5 "2021-07-12T21:02:28Z")

</div>

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