# Use the Dashboard variable in a code block

**URL:** <https://community.dynatrace.com/t/use-the-dashboard-variable-in-a-code-block/52113>\
**Category:** Dashboarding\
**Tags:** dashboards, javascript\
**Created:** [June 16, 2025, 10:59am UTC](https://community.dynatrace.com/t/use-the-dashboard-variable-in-a-code-block/52113 "2025-06-16T10:59:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmarbaix](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@jmarbaix](https://community.dynatrace.com/u/jmarbaix)\
**Post date:** [June 16, 2025, 10:59am UTC](https://community.dynatrace.com/t/use-the-dashboard-variable-in-a-code-block/52113/1 "2025-06-16T10:59:55Z")

</div>

I would like to use a dashboard variable in a code block, but I can’t seem find any documentation on how to do this. Is there even a way to do this?

---

<div class="post-metadata">

**Author:** ![jmarbaix](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@jmarbaix](https://community.dynatrace.com/u/jmarbaix)\
**Post date:** [June 16, 2025, 11:18am UTC](https://community.dynatrace.com/t/use-the-dashboard-variable-in-a-code-block/52113/2 "2025-06-16T11:18:22Z")

</div>

Found the solution, you just have to use the $-notation.

---

<div class="post-metadata">

**Author:** ![GerardJ](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/gerardj/32/154_2.png) [@GerardJ](https://community.dynatrace.com/u/GerardJ)\
**Post date:** [June 16, 2025, 11:21am UTC](https://community.dynatrace.com/t/use-the-dashboard-variable-in-a-code-block/52113/3 "2025-06-16T11:21:31Z")

</div>

Hello  
Yes it is possible the same way you use it in DQL. The exact syntax could depend on the type of variable and where it is used in the code. Here’s a simple example taken from the [Dynatrace Tenant Review](https://github.com/dynatrace-oss/CustomerSuccess) dashboard:

 ![GerardJ_0-1750072842786.png](https://global.discourse-cdn.com/dynatrace/original/2X/c/c9bde18c0fd00c7577d6b3fdebf7adcd0ad20569.png)
