# How to add the value count of 2 search results in Logstash

**URL:** <https://discuss.elastic.co/t/how-to-add-the-value-count-of-2-search-results-in-logstash/240153>\
**Category:** Logstash\
**Created:** [July 7, 2020, 11:48am UTC](https://discuss.elastic.co/t/how-to-add-the-value-count-of-2-search-results-in-logstash/240153 "2020-07-07T11:48:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matish\_Bhuyan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matish_bhuyan/32/68043_2.png) [@Matish\_Bhuyan](https://discuss.elastic.co/u/Matish_Bhuyan)\
**Post date:** [July 7, 2020, 11:48am UTC](https://discuss.elastic.co/t/how-to-add-the-value-count-of-2-search-results-in-logstash/240153/1 "2020-07-07T11:48:14Z")

</div>

Hi All,

I have written a scripted filed to add the count of these 2 values `Identity Accepted` and` Identity Rejected`.

These values are searched under` result` keyword

this is my scripted field

```
if (doc['result'].value == "Identity Accepted") && if (doc['result'].value == "Identity Rejected")
{
    "aggs" : {
        "total no of record processed" : "sum" : { "field" : "result" } }
}

```

but in kibana the field is showing this error

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

Please help me to fix this issue

---

<div class="post-metadata">

**Author:** ![Matish\_Bhuyan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matish_bhuyan/32/68043_2.png) [@Matish\_Bhuyan](https://discuss.elastic.co/u/Matish_Bhuyan)\
**Post date:** [July 7, 2020, 11:51am UTC](https://discuss.elastic.co/t/how-to-add-the-value-count-of-2-search-results-in-logstash/240153/2 "2020-07-07T11:51:35Z")

</div>

this is how my dashboard looks and i can't use the sum function given in Kibana as it will add the count value of all 3 results.

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

here as you can see total value is coming as 26 after adding all the 3 values

but i need to add the values of these 2

`Identity Accepted and Identity Rejected`

so the sum should come as 18.

---

<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:** [August 4, 2020, 11:51am UTC](https://discuss.elastic.co/t/how-to-add-the-value-count-of-2-search-results-in-logstash/240153/3 "2020-08-04T11:51:40Z")

</div>

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