# No filtering possibility with vega graph (when using aggregations to create the plot)

**URL:** <https://discuss.elastic.co/t/no-filtering-possibility-with-vega-graph-when-using-aggregations-to-create-the-plot/231006>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [May 4, 2020, 5:09pm UTC](https://discuss.elastic.co/t/no-filtering-possibility-with-vega-graph-when-using-aggregations-to-create-the-plot/231006 "2020-05-04T17:09:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nb03briceno](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nb03briceno/32/45777_2.png) [@nb03briceno](https://discuss.elastic.co/u/nb03briceno)\
**Post date:** [May 4, 2020, 5:09pm UTC](https://discuss.elastic.co/t/no-filtering-possibility-with-vega-graph-when-using-aggregations-to-create-the-plot/231006/1 "2020-05-04T17:09:40Z")

</div>

Hello everyone,

I would like to know why I can not use filters in Controls, or the general time filter, in a visualization that I developped in vega.

This is the code I have developed, and it seems to be that a simple functionality of kibana with controls is not working property in these cases. Would you mind giving me a suggestion??.

{  
$schema: [https://vega.github.io/schema/vega-lite/v2.6.0.json](https://vega.github.io/schema/vega-lite/v2.6.0.json)  
title: Orders  
%context%: true  
%timefield%: @timestamp

layer : [  
{  
data: {  
url: {

```
  index: hs_index
   "body": {
    "size": 0,
    "track_total_hits": true,
    "query": {
		"match": {
			"order_sent": "ORDER/INSERT"
				}
	},
    "aggregations": {
      "order_over_time_sent": {
        "date_histogram": {
          "field": "@timestamp",
          "format": "yyyy-MM-dd hh:mm-ss",
          "interval": "15m"
        }
      }
    }
  }
}
format: {property: "aggregations.order_over_time_sent.buckets"}

```

}  
mark: bar  
width: {"step": 12}  
encoding: {  
"column": {  
"field": "order\_sent",  
"type": "ordinal",  
"scale": {"padding": 4},  
"axis": {"orient": "bottom","axisWidth": 1,"offset": -8}  
},  
x: {  
field: key  
type: temporal  
axis: {title: "Time"}  
}  
y: {  
field: doc\_count  
type: quantitative  
axis: {title: "No. of orders"}  
}

```
 color: {"value": "#FF0000"},

legend: { title: '1' }

```

}  
},

{  
data: {  
url: {

```
  index: hs_index
   "body": {
    "size": 0,
    "track_total_hits": true,
    "query": {
		"match": {
			"order_rejected": "ORDER/INSERT/NAK"
				}
	},
    "aggregations": {
      "order_over_time_rejected": {
        "date_histogram": {
          "field": "@timestamp",
          "format": "yyyy-MM-dd hh:mm-ss",
          "interval": "15m"
        }
      }
    }
  }
}
format: {property: "aggregations.order_over_time_rejected.buckets"}

```

}  
mark: bar  
width: {"step": 12}  
encoding: {

```
"column": {
  "field": "order_rejected",
  "type": "ordinal",
  "scale": {"padding": 4},
  "axis": {"orient": "bottom","axisWidth": 1,"offset": -8}
}

x: {
  field: key
  type: temporal
  axis: {title: "Time"}
}
y: {
  field: doc_count
  type: quantitative
  axis: {title: "No. of orders"}
}

 color: {"value": "#006400"},

legend: { title: '1' }

```

}  
},

{  
data: {  
url: {

```
  index: hs_index
   "body": {
    "size": 0,
    "track_total_hits": true,
    "query": {
		"match": {
			"order_executed": "EXEC_FULL"
				}
	},
    "aggregations": {
      "order_over_time_executed": {
        "date_histogram": {
          "field": "@timestamp",
          "format": "yyyy-MM-dd hh:mm-ss",
          "interval": "15m"
        }
      }
    }
  }
}
format: {property: "aggregations.order_over_time_executed.buckets"}

```

}  
mark: bar  
width: {"step": 12}  
encoding: {  
"column": {  
"field": "order\_executed",  
"type": "ordinal",  
"scale": {"padding": 4},  
"axis": {"orient": "bottom","axisWidth": 1,"offset": -8}  
}

```
x: {
  field: key
  type: temporal
  axis: {title: "Time"}
}
y: {
  field: doc_count
  type: quantitative
  axis: {title: "No. of orders"}
}

 color: {"value": "#FFFF00"},

legend: { title: '1' }

```

}  
}

]  
}

(How I could be able to filter the graph in a dashboard in order to for example see the values of a particular day and not all the data stored in the index?)

this is the graph.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/6/063d6b8e983db6c2982977a334d240b5e886d9ae.jpeg)

I'm going to be really grateful if somebody could help me with this issue.

JUAN DAVID BRICENO GUERRERO

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [May 4, 2020, 10:04pm UTC](https://discuss.elastic.co/t/no-filtering-possibility-with-vega-graph-when-using-aggregations-to-create-the-plot/231006/2 "2020-05-04T22:04:26Z")

</div>

You can add filters using the guide from this PR: [https://github.com/elastic/kibana/pull/17586](https://github.com/elastic/kibana/pull/17586)

---

<div class="post-metadata">

**Author:** ![nb03briceno](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nb03briceno/32/45777_2.png) [@nb03briceno](https://discuss.elastic.co/u/nb03briceno)\
**Post date:** [May 5, 2020, 7:27am UTC](https://discuss.elastic.co/t/no-filtering-possibility-with-vega-graph-when-using-aggregations-to-create-the-plot/231006/3 "2020-05-05T07:27:18Z")

</div>

Marius Dragomir,

thanks so much for your reply, yet could you explain me in few words how it works? or somehow, how/where may I have to add it in my code?

Thank for helping!

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [May 7, 2020, 12:32pm UTC](https://discuss.elastic.co/t/no-filtering-possibility-with-vega-graph-when-using-aggregations-to-create-the-plot/231006/4 "2020-05-07T12:32:39Z")

</div>

Sorry, I don't really know more about it that what it's described in the PR comments and description.

---

<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:** [June 4, 2020, 12:32pm UTC](https://discuss.elastic.co/t/no-filtering-possibility-with-vega-graph-when-using-aggregations-to-create-the-plot/231006/5 "2020-06-04T12:32:42Z")

</div>

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