# How to set max value of gauge panel by using query

**URL:** <https://community.grafana.com/t/how-to-set-max-value-of-gauge-panel-by-using-query/126118>\
**Category:** Dashboards\
**Created:** [July 12, 2024, 5:37pm UTC](https://community.grafana.com/t/how-to-set-max-value-of-gauge-panel-by-using-query/126118 "2024-07-12T17:37:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bujna94](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@bujna94](https://community.grafana.com/u/bujna94)\
**Post date:** [July 12, 2024, 5:37pm UTC](https://community.grafana.com/t/how-to-set-max-value-of-gauge-panel-by-using-query/126118/1 "2024-07-12T17:37:05Z")

</div>

![Screenshot 2024-07-13 at 12.34.25 AM](https://us1.discourse-cdn.com/grafana/original/3X/7/a/7a0953afff3f3b9a0bfd8bab5c6290d1e49fc884.jpeg)

Hi, how can I make this gauge display properly? I have just 13 devices, but the gauge is showing 100.

Thanks

---

<div class="post-metadata">

**Author:** ![jangaraj](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jangaraj/32/39197_2.png) [@jangaraj](https://community.grafana.com/u/jangaraj)\
**Post date:** [July 12, 2024, 7:06pm UTC](https://community.grafana.com/t/how-to-set-max-value-of-gauge-panel-by-using-query/126118/2 "2024-07-12T19:06:17Z")

</div>

Gauges has `Min` - `Max` range:

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/2/2/2220b62953b487dc082aa6ba6c67da34769b8760.png)

So just set `Min`, `Max` configs for your case.

---

<div class="post-metadata">

**Author:** ![bujna94](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@bujna94](https://community.grafana.com/u/bujna94)\
**Post date:** [July 12, 2024, 7:22pm UTC](https://community.grafana.com/t/how-to-set-max-value-of-gauge-panel-by-using-query/126118/3 "2024-07-12T19:22:37Z")

</div>

of course. but the number of devices can change every day, I need it to set to COUNT of the devices

This is example for Stat I have with count of devices and it works

```auto
SELECT COUNT(DISTINCT("device_id")) FROM (
  SELECT LAST("status") AS "status" FROM "heartbeat" GROUP BY "device_id"
)

```

---

<div class="post-metadata">

**Author:** ![jangaraj](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jangaraj/32/39197_2.png) [@jangaraj](https://community.grafana.com/u/jangaraj)\
**Post date:** [July 12, 2024, 8:22pm UTC](https://community.grafana.com/t/how-to-set-max-value-of-gauge-panel-by-using-query/126118/4 "2024-07-12T20:22:52Z")

</div>

> [@bujna94](#):
>
> This is example for Stat I have with count of devices and it works
> 
> ```auto
> SELECT COUNT(DISTINCT("device_id")) FROM (
> SELECT LAST("status") AS "status" FROM "heartbeat" GROUP BY "device_id"
> )
> 
> ```

Add it as third query and then add `Config from query results` transformation, where you use result from this query to set `Max` config of the panel. Example:

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/d/c/dc0cd1ee8f22703aa1a09c558620503314825ed8.png)

---

<div class="post-metadata">

**Author:** ![bujna94](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@bujna94](https://community.grafana.com/u/bujna94)\
**Post date:** [July 12, 2024, 8:40pm UTC](https://community.grafana.com/t/how-to-set-max-value-of-gauge-panel-by-using-query/126118/5 "2024-07-12T20:40:07Z")

</div>

![Screenshot 2024-07-13 at 3.44.23 AM](https://us1.discourse-cdn.com/grafana/original/3X/a/c/acb72dcf0d97a7b497df6f0bd050f19f57bd657a.jpeg)  
it helped with the ‘inner green’ but the main thin one is still 1-100

---

<div class="post-metadata">

**Author:** ![jangaraj](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jangaraj/32/39197_2.png) [@jangaraj](https://community.grafana.com/u/jangaraj)\
**Post date:** [July 12, 2024, 8:50pm UTC](https://community.grafana.com/t/how-to-set-max-value-of-gauge-panel-by-using-query/126118/6 "2024-07-12T20:50:08Z")

</div>

Provide reproducible example first,pls.
