# Global Variables in Canvas

**URL:** <https://discuss.elastic.co/t/global-variables-in-canvas/169871>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [February 25, 2019, 4:08pm UTC](https://discuss.elastic.co/t/global-variables-in-canvas/169871 "2019-02-25T16:08:18Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)\
**Post date:** [March 11, 2019, 8:14pm UTC](https://discuss.elastic.co/t/global-variables-in-canvas/169871/3 "2019-03-11T20:14:28Z")

</div>

@JamesNotJamez There's not a way to create a "global" value directly, but you could perhaps use the `urlparam` function as a substitute here. That function allows you to read a value from query params in the URL.

When you have a workpad open, the URL in your browser should look something like this: `http://localhost:5601/app/canvas#/workpad/...`

You can add query params before the `#` in there, like so: `http://localhost:5601/app/canvas?target=5000#/workpad/`

So now you have a query param named `target`, which you can use with the following expression:

```auto
urlparam param=target default=1000

```

This will read the value of `target` in the url, and if it's not set, default the value to 1000. In the URL I used above there, the value would be 5000. You can use it as a subexpression to get the value of the upper bound. As a simple and somewhat contrived example:

```auto
escount index="your-index-or-index-pattern"
| math {string "value / " {urlparam param=target default=1000}}

```

Now when you want to adjust the goal value, you can just set a new value in the URL, and it will simply use 1000 by default.

The downside is that the value in the URL isn't preserved, if you just open the workpad like normal, the value won't be there, and it'll fall back to 1000. This really only works for situations where you are linking to a workpad directly somewhere.

You gave me an interesting idea for the application though; the ability to define arbitrary metadata on a workpad, which _would_ persist, and would be easy enough to modify to update all elements. I've opened an enhancement issue to track that idea here, feel free to follow or comment: [https://github.com/elastic/kibana/issues/32928](https://github.com/elastic/kibana/issues/32928)

---

_[View the full topic](https://discuss.elastic.co/t/global-variables-in-canvas/169871)._
