# Weird behaviour with gauge with gauge visualization

**URL:** <https://community.grafana.com/t/weird-behaviour-with-gauge-with-gauge-visualization/72617>\
**Category:** Bar Gauge Panel\
**Tags:** bar-gauge, mssql\
**Created:** [September 19, 2022, 5:39am UTC](https://community.grafana.com/t/weird-behaviour-with-gauge-with-gauge-visualization/72617 "2022-09-19T05:39:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgalan1](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@jgalan1](https://community.grafana.com/u/jgalan1)\
**Post date:** [September 19, 2022, 5:39am UTC](https://community.grafana.com/t/weird-behaviour-with-gauge-with-gauge-visualization/72617/1 "2022-09-19T05:39:28Z")

</div>

Hi,  
I´m working with a SQL server, and I wanted to do some porcentages with the gauge tool. I did my querys to get 1 value per query, I reduced the query to an expression (max, mode strict) and I operated them with operation: math.

I´m new working with SQL and Grafana, and probably exists ways to improve my code.

Each gauge has 14 querys similar to:  
declare @1d datetime  
set @1d = DATEADD(day,-1, GETDATE())

SELECT TAG AS METRIC, TEP AS VALUE,  
CAST (TMDT as datetime) as time  
FROM DATOS  
WHERE TAG = ‘XX’ and tmdt \< @1d  
ORDER BY time

and retorn values, 14 reduce expressions and 1 math expression. 5 gauges.

All those operations worked well for some minutes, but I´m having problems when I reduce some of this values, getting me NaN values. I´m not sure if it´s happen because of a bug (If i do 3-4 querys, reduces, etc, it works fine, but with all operations that i need the wrong values happen), or i´m overcharging the tool, or any other error you can see.

Regards.

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [September 19, 2022, 1:32pm UTC](https://community.grafana.com/t/weird-behaviour-with-gauge-with-gauge-visualization/72617/2 "2022-09-19T13:32:29Z")

</div>

> [@jgalan1](#):
>
> Each gauge has 14 querys

Welcome

Few questions here.

1. Do you mean you have 14 gauges with 1 query each?
2. Are you querying one tag per query. Is that the reaaon you have TAG = XXX

Instead of doing a lot of post processing of your data in grafana with transformations I would recommend you do it all in sql server query itself

---

<div class="post-metadata">

**Author:** ![jgalan1](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@jgalan1](https://community.grafana.com/u/jgalan1)\
**Post date:** [September 21, 2022, 5:51am UTC](https://community.grafana.com/t/weird-behaviour-with-gauge-with-gauge-visualization/72617/3 "2022-09-21T05:51:57Z")

</div>

Hi Yosiasz,

Thanks for your response.

1. I have just 1 visual gauge per graphic, but I need to do some querys, reduces expressions and math expressions to get what I need. My skills on SQL are poor, because of that I do so many querys in Grafana.

2. Yes, my “XXX” refers to diferent Tags. I simply did “copy and paste” my query. Actually I do 2 differents querys for the same Tag, with different range of time, to compare their values.

I´ve done some changes in the operations, and I saw if I reduce a math expression it works better than reduce a query. I don´t know if the problem is for working reducing querys, or simply for so many expressions in the same gauge.

Thanks for your time, J
