# Calculate success count in Visualization using JSON Input

**URL:** <https://discuss.elastic.co/t/calculate-success-count-in-visualization-using-json-input/227752>\
**Category:** Elasticsearch\
**Created:** [April 13, 2020, 9:51am UTC](https://discuss.elastic.co/t/calculate-success-count-in-visualization-using-json-input/227752 "2020-04-13T09:51:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohitarora275](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rohitarora275/32/66210_2.png) [@rohitarora275](https://discuss.elastic.co/u/rohitarora275)\
**Post date:** [April 13, 2020, 9:51am UTC](https://discuss.elastic.co/t/calculate-success-count-in-visualization-using-json-input/227752/1 "2020-04-13T09:51:57Z")

</div>

Hi All,

I am new to ELK stack, I want to implement a logic to find the count of daily success transactions on the basis of a field **status** (if status = "S" it is success).  
I have implemented this logic by creating an scripted field (if status = S then set scripted field = 1) and then in the visualization , I have created a sum metric and I have got the count of daily success.

My question is, Is there a workaround to handle the complete logic in visualization rather than calculating at each field because calculating at field level may impact the performance?

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [April 13, 2020, 10:17am UTC](https://discuss.elastic.co/t/calculate-success-count-in-visualization-using-json-input/227752/2 "2020-04-13T10:17:10Z")

</div>

Hello @rohitarora275

If I correctly understood, you want some directions on how to create a filtered visualization.

It is not necessary to define the scripted field for this kind of visualizations. Remove it.

In any visualization, you can use the `count` metric.  
It will count the documents matching your filter, which you can add in the upper part of the dashboard.

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

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

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

Another approach is to split the series (the `Buckets` part) using the `Filters`:

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

---

<div class="post-metadata">

**Author:** ![rohitarora275](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rohitarora275/32/66210_2.png) [@rohitarora275](https://discuss.elastic.co/u/rohitarora275)\
**Post date:** [April 14, 2020, 12:44pm UTC](https://discuss.elastic.co/t/calculate-success-count-in-visualization-using-json-input/227752/3 "2020-04-14T12:44:58Z")

</div>

Hi Luca\_Belluccini,

Thanks for your reply, but here I have to display three values Success count, Total count and exception count.

With the help of your logic, I will be able to display only one count ,

Can you please help on this

 ![VisualizationScreen](https://us1.discourse-cdn.com/elastic/original/3X/c/9/c94b798fd8b89d61929d7763c5ac4800f5098fe8.png)

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [April 14, 2020, 1:11pm UTC](https://discuss.elastic.co/t/calculate-success-count-in-visualization-using-json-input/227752/4 "2020-04-14T13:11:02Z")

</div>

You can use 3 `Filters` using the `Filters` sub aggregation: one for `success` one for `exception` and another for `total`.

---

<div class="post-metadata">

**Author:** ![rohitarora275](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rohitarora275/32/66210_2.png) [@rohitarora275](https://discuss.elastic.co/u/rohitarora275)\
**Post date:** [April 15, 2020, 4:01pm UTC](https://discuss.elastic.co/t/calculate-success-count-in-visualization-using-json-input/227752/5 "2020-04-15T16:01:01Z")

</div>

Thanks Luca\_Belluccini, I am able to get three different count in three rows

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [April 16, 2020, 10:59pm UTC](https://discuss.elastic.co/t/calculate-success-count-in-visualization-using-json-input/227752/6 "2020-04-16T22:59:58Z")

</div>

> [@rohitarora275](#):
>
> Thanks Luca\_Belluccini, I am able to get three different count in three rows

@rohitarora275 glad it solved the issue!

Please mark the question as answered if possible.

---

<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:** [May 14, 2020, 11:01pm UTC](https://discuss.elastic.co/t/calculate-success-count-in-visualization-using-json-input/227752/7 "2020-05-14T23:01:43Z")

</div>

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