# Create button with filters in dashboards

**URL:** https://discuss.elastic.co/t/create-button-with-filters-in-dashboards/336243
**Category:** Kibana
**Tags:** kql-kibana-query-language, kibana-plugin-development
**Created:** [June 16, 2023, 3:06pm UTC](https://discuss.elastic.co/t/create-button-with-filters-in-dashboards/336243 "2023-06-16T15:06:53Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![SYGH](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@SYGH](https://discuss.elastic.co/u/SYGH)
#### Post date: [June 16, 2023, 3:06pm UTC](https://discuss.elastic.co/t/create-button-with-filters-in-dashboards/336243/1 "2023-06-16T15:06:53Z")

</div>

Hello, I need to create a button on the dashboard to enable a filter based on the value of X. At the same time, when you click it again, the filter is removed. Please tell me how to create this button.

---

<div class="post-metadata">

### Author: ![Priscilla\_Parodi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priscilla_parodi/32/43047_2.png) [@Priscilla\_Parodi](https://discuss.elastic.co/u/Priscilla_Parodi)
#### Post date: [June 16, 2023, 3:35pm UTC](https://discuss.elastic.co/t/create-button-with-filters-in-dashboards/336243/2 "2023-06-16T15:35:34Z")

</div>

Hello @SYGH,

Welcome to the community!

Which version of Elastic are you using? You can use [Kibana Controls](https://www.elastic.co/guide/en/kibana/8.8/add-controls.html) and add the filter panel to your dashboard.

---

<div class="post-metadata">

### Author: ![SYGH](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@SYGH](https://discuss.elastic.co/u/SYGH)
#### Post date: [June 16, 2023, 4:00pm UTC](https://discuss.elastic.co/t/create-button-with-filters-in-dashboards/336243/3 "2023-06-16T16:00:48Z")

</div>

I use Elastic Stack v 7.17.9. I known about controls, but I don't want to use them because I don't want to enter a value every time.

---

<div class="post-metadata">

### Author: ![Priscilla\_Parodi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priscilla_parodi/32/43047_2.png) [@Priscilla\_Parodi](https://discuss.elastic.co/u/Priscilla_Parodi)
#### Post date: [June 16, 2023, 4:56pm UTC](https://discuss.elastic.co/t/create-button-with-filters-in-dashboards/336243/4 "2023-06-16T16:56:36Z")

</div>

In this case you can simply save a filter to your Dashboard.

Click on Add Filter \> edit your filter \> Save

 ![IMG_1483](https://us1.discourse-cdn.com/elastic/original/3X/f/f/ffe7b927b65ebbe74cf922c8d492d37faf58c9d5.jpeg)

---

<div class="post-metadata">

### Author: ![Priscilla\_Parodi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priscilla_parodi/32/43047_2.png) [@Priscilla\_Parodi](https://discuss.elastic.co/u/Priscilla_Parodi)
#### Post date: [June 16, 2023, 5:04pm UTC](https://discuss.elastic.co/t/create-button-with-filters-in-dashboards/336243/5 "2023-06-16T17:04:37Z")

</div>

Note: You can disable and re-enable the saved filter whenever you want, so there's no need to delete it and create a new one each time.

 ![IMG_1485](https://us1.discourse-cdn.com/elastic/original/3X/8/8/8815e2fb4c1ae439cab487aac46021b0e20fba57.jpeg)

 ![IMG_1486](https://us1.discourse-cdn.com/elastic/original/3X/2/1/21b66a28cd54ec709e34bf793162b974e486a4c9.jpeg)

---

<div class="post-metadata">

### Author: ![SYGH](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@SYGH](https://discuss.elastic.co/u/SYGH)
#### Post date: [June 19, 2023, 12:39pm UTC](https://discuss.elastic.co/t/create-button-with-filters-in-dashboards/336243/6 "2023-06-19T12:39:35Z")

</div>

I know about such a feature, but I want to create a button in the dashboard itself for filtering.  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/e/2ee8be9eae7bd861568bbf1ceb0dc3f6b7f545e3.png)  
I was able to write the code for the button, but I don't know how to modify it so that it sets the filter when clicked.

```auto
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "title": "Filter by mccmnc",
  "signals": [
    {"name": "filterMCCMNC", "init": null}
  ],
  "data": {"url": {"%context%": true, "index": "edr-*"}},
  "selection": {
    "click": {
      "type": "single",
      "fields": ["mccmnc"],
      "init": {"mccmnc": "XXXXXX"},
      "bind": {
        "input": "checkbox",
        "name": "X",
        "description": "Filter by X",
        "value": "XXXXXX"
      }
    }
  },
  "autosize": "none"
  "width": "2cm",
  "height": "3cm",
  "mark": "rect",
  "encoding": {
    "color": {"value": "lightgray"}
  },
  "transform": [{"filter": {"selection": "click"}}]
}

```

---

<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: [July 17, 2023, 12:40pm UTC](https://discuss.elastic.co/t/create-button-with-filters-in-dashboards/336243/7 "2023-07-17T12:40:15Z")

</div>

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