# Sum of distinct values in field

**URL:** <https://discuss.elastic.co/t/sum-of-distinct-values-in-field/112028>\
**Category:** Elasticsearch\
**Created:** [December 15, 2017, 5:43pm UTC](https://discuss.elastic.co/t/sum-of-distinct-values-in-field/112028 "2017-12-15T17:43:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![scch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/scch/32/25504_2.png) [@scch](https://discuss.elastic.co/u/scch)\
**Post date:** [December 15, 2017, 5:43pm UTC](https://discuss.elastic.co/t/sum-of-distinct-values-in-field/112028/1 "2017-12-15T17:43:14Z")

</div>

Hi..  
I am trying to sum values of 'Field 2' as per unique value stored in another 'Field 1'

index **\_color**

**Field 1** ------------------- **Field 2**  
Red-------------------------------2  
Orange-------------------------5  
Red-----------------------------2  
Green-------------------------3  
Green-----------------------3  
Orange--------------------5  
Red------------------------2

So my answer should be 2+5+3=10  
How to do that....

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:** [January 12, 2018, 5:43pm UTC](https://discuss.elastic.co/t/sum-of-distinct-values-in-field/112028/2 "2018-01-12T17:43:22Z")

</div>

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