# Function replace by variable (dropdown selection)

**URL:** <https://community.dynatrace.com/t/function-replace-by-variable-dropdown-selection/45262>\
**Category:** DQL\
**Tags:** dql, dashboards\
**Created:** [April 23, 2024, 2:02pm UTC](https://community.dynatrace.com/t/function-replace-by-variable-dropdown-selection/45262 "2024-04-23T14:02:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wbolten](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/wbolten/32/13591_2.png) [@wbolten](https://community.dynatrace.com/u/wbolten)\
**Post date:** [April 23, 2024, 2:02pm UTC](https://community.dynatrace.com/t/function-replace-by-variable-dropdown-selection/45262/1 "2024-04-23T14:02:47Z")

</div>

Hi,

I have a panel with the below timeseries command and it is working. However they would like to be able to change from avg to max, or other ones for that matter and without the need to change the DQL everytime in the panel.

I am doing a similar thing with dropdown values on the dashboard for the threshold of the disk usage. Doing the same for the avg to change it to max is not working.

Possible options are: min, max, avg

```markup
timeseries diskusage = avg(dt.host.disk.used.percent), by:{dt.entity.host,dt.entity.disk}, interval:1d

```

Any suggestions?

[@marina\_pollehn](https://community.dynatrace.com/user/2456)

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [April 23, 2024, 8:41pm UTC](https://community.dynatrace.com/t/function-replace-by-variable-dropdown-selection/45262/2 "2024-04-23T20:41:11Z")

</div>

Variable value is a quoted string, so it is not possible to use it as a command or function in the query, but you can check such query:

```markup
timeseries {
avg_diskusage = avg(dt.host.disk.used.percent), 
min_diskusage = avg(dt.host.disk.used.percent), 
max_diskusage = avg(dt.host.disk.used.percent) },
by:{dt.entity.host,dt.entity.disk}, interval:1d
| fields diskusage=coalesce( 
    if($function=="max", max_diskusage),
    if($function=="min", min_diskusage),
    avg_diskusage ), interval, timeframe, dt.entity.host, dt.entity.disk

```

together with this definition of variable:

 ![krzysztof_hoja_0-1713904731815.png](https://global.discourse-cdn.com/dynatrace/original/2X/3/3d6dd637405bab1dc3f4dea5475300e8ce890f48.png)

Kris

---

<div class="post-metadata">

**Author:** ![marina\_pollehn](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/marina_pollehn/32/39120_2.png) [@marina\_pollehn](https://community.dynatrace.com/u/marina_pollehn)\
**Post date:** [April 24, 2024, 11:20am UTC](https://community.dynatrace.com/t/function-replace-by-variable-dropdown-selection/45262/3 "2024-04-24T11:20:40Z")

</div>

Hero! Works for me 🙂 Made a small correction to the operators.

timeseries {  
avg\_diskusage = avg(dt.host.disk.used.percent),  
min\_diskusage = min(dt.host.disk.used.percent),  
max\_diskusage = max(dt.host.disk.used.percent) },

Thank you so much!!!

---

<div class="post-metadata">

**Author:** ![wbolten](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/wbolten/32/13591_2.png) [@wbolten](https://community.dynatrace.com/u/wbolten)\
**Post date:** [April 24, 2024, 12:44pm UTC](https://community.dynatrace.com/t/function-replace-by-variable-dropdown-selection/45262/4 "2024-04-24T12:44:55Z")

</div>

Hi&nbsp;[@krzysztof\_hoja](https://community.dynatrace.com/user/25373)

This is an excellent work around and exactly what we needed.&nbsp;[@marina\_pollehn](https://community.dynatrace.com/user/2456)&nbsp;already adjusted the panel on our side and it is working as expected.

Thank you.

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [April 24, 2024, 2:41pm UTC](https://community.dynatrace.com/t/function-replace-by-variable-dropdown-selection/45262/5 "2024-04-24T14:41:56Z")

</div>

Thx for correction. “ctrl-c” + “ctrl-v”&nbsp;😉

Kris
