# Stat Panel Result of Division showing NaN?

**URL:** <https://community.grafana.com/t/stat-panel-result-of-division-showing-nan/104815>\
**Category:** InfluxDB\
**Created:** [October 3, 2023, 1:50pm UTC](https://community.grafana.com/t/stat-panel-result-of-division-showing-nan/104815 "2023-10-03T13:50:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattcprotzman](https://avatars.discourse-cdn.com/v4/letter/m/4da419/32.png) [@mattcprotzman](https://community.grafana.com/u/mattcprotzman)\
**Post date:** [October 3, 2023, 1:50pm UTC](https://community.grafana.com/t/stat-panel-result-of-division-showing-nan/104815/1 "2023-10-03T13:50:19Z")

</div>

- **What** are you trying to achieve?  
A percentage of uptime based on a response to a ping @ :22

- **How** are you trying to achieve it?  
I’m using the [[inputs.net\_response]] plugin to see a servers uptime. I’m sending a tcp ping at :22 and using the response from that.

I’ve formed 2 queries,  
count of result code where the result is “success”  
count of result code where the result is anything  
divide success/all using the transform panel

 ![Screenshot 2023-10-03 at 9.38.20 AM](https://us1.discourse-cdn.com/grafana/original/3X/1/c/1c248418d3c7a737b827239192372da9c9253b86.png)

- What happened?  
if I divide success/all i should receive a percentage of successful results. However, I receive NaN as the result of the divison. The number of successful / total queries is correct - 6 hour time frame \* 60 minutes \* 10s interval = 2160 entries.

- What did you **expect** to happen?  
I would expect that the division would return “1” which I could then turn into a percentage.

---

<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:** [October 3, 2023, 1:58pm UTC](https://community.grafana.com/t/stat-panel-result-of-division-showing-nan/104815/2 "2023-10-03T13:58:30Z")

</div>

How and where are you doing this calculation?

---

<div class="post-metadata">

**Author:** ![fadjar340](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/fadjar340/32/10236_2.png) [@fadjar340](https://community.grafana.com/u/fadjar340)\
**Post date:** [October 3, 2023, 2:10pm UTC](https://community.grafana.com/t/stat-panel-result-of-division-showing-nan/104815/3 "2023-10-03T14:10:45Z")

</div>

I think the result in string…  
Before calculation, please convert the result first to number in the transformation, then do the calculation.

Regards,  
Fadjar

---

<div class="post-metadata">

**Author:** ![mattcprotzman](https://avatars.discourse-cdn.com/v4/letter/m/4da419/32.png) [@mattcprotzman](https://community.grafana.com/u/mattcprotzman)\
**Post date:** [October 3, 2023, 2:16pm UTC](https://community.grafana.com/t/stat-panel-result-of-division-showing-nan/104815/4 "2023-10-03T14:16:23Z")

</div>

I wasn’t aware of the convert field type before - is this what you’re referring to? I’m still getting NaN after converting to Numeric.

 ![Screenshot 2023-10-03 at 10.13.44 AM](https://us1.discourse-cdn.com/grafana/original/3X/e/8/e8d42acf7d5b8d0e7f039f178152c2e5a148d584.png)

---

<div class="post-metadata">

**Author:** ![mattcprotzman](https://avatars.discourse-cdn.com/v4/letter/m/4da419/32.png) [@mattcprotzman](https://community.grafana.com/u/mattcprotzman)\
**Post date:** [October 3, 2023, 2:17pm UTC](https://community.grafana.com/t/stat-panel-result-of-division-showing-nan/104815/5 "2023-10-03T14:17:11Z")

</div>

The calculation is happening in the transform tab - see the screenshot in the other reply I just tossed in.

---

<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:** [October 3, 2023, 2:28pm UTC](https://community.grafana.com/t/stat-panel-result-of-division-showing-nan/104815/6 "2023-10-03T14:28:39Z")

</div>

what if you tried this approach? I am mocking your data using ms sql with mixed data source and the 3rd data source is an expression

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/5/1/51b9ccc03712d81202dbf9e8d2c9894366823094.png)
