# Correct syntax for adding a filter aggregation in a Kibana visualization as a JSON input (filtering for a specific property value)

**URL:** https://discuss.elastic.co/t/correct-syntax-for-adding-a-filter-aggregation-in-a-kibana-visualization-as-a-json-input-filtering-for-a-specific-property-value/255638
**Category:** Kibana
**Created:** [November 17, 2020, 8:29am UTC](https://discuss.elastic.co/t/correct-syntax-for-adding-a-filter-aggregation-in-a-kibana-visualization-as-a-json-input-filtering-for-a-specific-property-value/255638 "2020-11-17T08:29:59Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![rputla](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@rputla](https://discuss.elastic.co/u/rputla)
#### Post date: [November 17, 2020, 8:29am UTC](https://discuss.elastic.co/t/correct-syntax-for-adding-a-filter-aggregation-in-a-kibana-visualization-as-a-json-input-filtering-for-a-specific-property-value/255638/1 "2020-11-17T08:29:59Z")

</div>

Hi all, I am new to ELK stack.  
can you please help me with below requirement.  
I am trying to create a metric based on condition like sum( sales) for region ="Middle East"  
I have tried using the sum bucket in aggregation and using filter in bucket , I am able to achieve it but I am not able to change the name of the field ( give a custom label ).  
Is there any way to change the field name ? How can we achieve this using json input or scripted field ?

---

<div class="post-metadata">

### Author: ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)
#### Post date: [November 17, 2020, 3:06pm UTC](https://discuss.elastic.co/t/correct-syntax-for-adding-a-filter-aggregation-in-a-kibana-visualization-as-a-json-input-filtering-for-a-specific-property-value/255638/2 "2020-11-17T15:06:55Z")

</div>

Are you looking to do something like this in the KQL search bar `region.keyword: "Middle East"`? That will filter the entire dataset down to just the `Middle East` and then you can do a normal `sum(sales)` to get the data.

---

<div class="post-metadata">

### Author: ![rputla](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@rputla](https://discuss.elastic.co/u/rputla)
#### Post date: [November 18, 2020, 7:16am UTC](https://discuss.elastic.co/t/correct-syntax-for-adding-a-filter-aggregation-in-a-kibana-visualization-as-a-json-input-filtering-for-a-specific-property-value/255638/3 "2020-11-18T07:16:37Z")

</div>

No, I just want the metric to be filtered.  
My actual requirement is  
I have two metrics that need individual filters  
Metric 1 = avg(sales) filter: class=A  
Metric 2 = avg(sales) filter: class=B  
and then find the difference of metric 1and metric 2

---

<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: [December 16, 2020, 7:16am UTC](https://discuss.elastic.co/t/correct-syntax-for-adding-a-filter-aggregation-in-a-kibana-visualization-as-a-json-input-filtering-for-a-specific-property-value/255638/4 "2020-12-16T07:16:48Z")

</div>

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