# How to get a number on my dasboard instead of a string

**URL:** <https://discourse.nodered.org/t/how-to-get-a-number-on-my-dasboard-instead-of-a-string/33978>\
**Category:** General\
**Created:** [9 October 2020 07:00 UTC](https://discourse.nodered.org/t/how-to-get-a-number-on-my-dasboard-instead-of-a-string/33978 "2020-10-09T07:00:05Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![iTzBrilliiiant](https://avatars.discourse-cdn.com/v4/letter/i/2acd7d/32.png) [@iTzBrilliiiant](https://discourse.nodered.org/u/iTzBrilliiiant)\
**Post date:** [9 October 2020 07:00 UTC](https://discourse.nodered.org/t/how-to-get-a-number-on-my-dasboard-instead-of-a-string/33978/1 "2020-10-09T07:00:05Z")

</div>

Hello,

I can get data out of my database but when i display it in my gauge i get a string. How could i get a number instead of a string? Also im getting my data in a array out of my database.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/3/a3957a487efd43394557c601e4cf0139c301f7fa.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/c/ac259fc3b0afb23234cdd6c9321a2649efb16be7.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [9 October 2020 07:59 UTC](https://discourse.nodered.org/t/how-to-get-a-number-on-my-dasboard-instead-of-a-string/33978/2 "2020-10-09T07:59:03Z")

</div>

While 'a picture is worth a thousand words' is true most of the time, in this case, a copy of your flow would give more information.

also what does the `debug` node show?

---

<div class="post-metadata">

**Author:** ![iTzBrilliiiant](https://avatars.discourse-cdn.com/v4/letter/i/2acd7d/32.png) [@iTzBrilliiiant](https://discourse.nodered.org/u/iTzBrilliiiant)\
**Post date:** [9 October 2020 08:15 UTC](https://discourse.nodered.org/t/how-to-get-a-number-on-my-dasboard-instead-of-a-string/33978/3 "2020-10-09T08:15:36Z")

</div>

This is the output of my flow  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/9/89a4b2609c85cd7189a7ccfeda3c09b6ce40da98.png)

```auto
[{"id":"434c8281.163c2c","type":"MSSQL","z":"c8a025bb.cf5478","mssqlCN":"302f4b9a.eb6754","name":"Database Plenion","query":"","outField":"payload","x":570,"y":140,"wires":[["c0c7cf9d.781f8","d49ed4b2.c82a18"]]},{"id":"302f4b9a.eb6754","type":"MSSQL-CN","z":"","name":"localhostpleniondata","server":"localhost","encyption":true,"database":"PlenionData"}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [9 October 2020 08:16 UTC](https://discourse.nodered.org/t/how-to-get-a-number-on-my-dasboard-instead-of-a-string/33978/4 "2020-10-09T08:16:39Z")

</div>

and the export of the flow??

---

<div class="post-metadata">

**Author:** ![iTzBrilliiiant](https://avatars.discourse-cdn.com/v4/letter/i/2acd7d/32.png) [@iTzBrilliiiant](https://discourse.nodered.org/u/iTzBrilliiiant)\
**Post date:** [9 October 2020 08:43 UTC](https://discourse.nodered.org/t/how-to-get-a-number-on-my-dasboard-instead-of-a-string/33978/5 "2020-10-09T08:43:20Z")

</div>

There is a flow there

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [9 October 2020 08:52 UTC](https://discourse.nodered.org/t/how-to-get-a-number-on-my-dasboard-instead-of-a-string/33978/6 "2020-10-09T08:52:56Z")

</div>

What you added to that post only the mssql node not the complete flow.

---

<div class="post-metadata">

**Author:** ![iTzBrilliiiant](https://avatars.discourse-cdn.com/v4/letter/i/2acd7d/32.png) [@iTzBrilliiiant](https://discourse.nodered.org/u/iTzBrilliiiant)\
**Post date:** [9 October 2020 08:57 UTC](https://discourse.nodered.org/t/how-to-get-a-number-on-my-dasboard-instead-of-a-string/33978/7 "2020-10-09T08:57:16Z")

</div>

It is indeed the full flow that i use

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [9 October 2020 09:03 UTC](https://discourse.nodered.org/t/how-to-get-a-number-on-my-dasboard-instead-of-a-string/33978/8 "2020-10-09T09:03:52Z")

</div>

what you posted as your flow is only the `mssql` node. When you did the export, at the top of the window it has three choices

- selected nodes
- current flow
- all flows  
the default is `selected nodes`, you should choose `current flow`

---

<div class="post-metadata">

**Author:** ![iTzBrilliiiant](https://avatars.discourse-cdn.com/v4/letter/i/2acd7d/32.png) [@iTzBrilliiiant](https://discourse.nodered.org/u/iTzBrilliiiant)\
**Post date:** [9 October 2020 09:06 UTC](https://discourse.nodered.org/t/how-to-get-a-number-on-my-dasboard-instead-of-a-string/33978/9 "2020-10-09T09:06:56Z")

</div>

```auto
[{"id":"c8a025bb.cf5478","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"8095f328.b0aa7","type":"ui_gauge","z":"c8a025bb.cf5478","name":"","group":"dfaa887.1429078","order":1,"width":0,"height":0,"gtype":"gage","title":"New Client requests","label":"","format":"{{value}}","min":0,"max":"20","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1200,"y":200,"wires":[]},{"id":"5699253a.ce38cc","type":"MSSQL","z":"c8a025bb.cf5478","mssqlCN":"565085c1.c65bcc","name":"Database Plenion","query":"","outField":"payload","x":770,"y":200,"wires":[["61840ed6.9a7a9","83a96980.17a7b8"]]},{"id":"5de0d118.7af75","type":"inject","z":"c8a025bb.cf5478","name":"Select statement New client requests","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"30","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"SELECT count(*) FROM Req WHERE Volgendestap_rqv = '33827'","payloadType":"str","x":430,"y":200,"wires":[["5699253a.ce38cc"]]},{"id":"61840ed6.9a7a9","type":"debug","z":"c8a025bb.cf5478","name":"Debug data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":950,"y":140,"wires":[]},{"id":"83a96980.17a7b8","type":"function","z":"c8a025bb.cf5478","name":"","func":"/* //read payload\nvar stringValue = msg.payload;\n\n//convert string to float to 2 decimal places\nvar floatValue = parseFloat(stringValue).toFixed(2);\n\n//set and return payload\nmsg.payload = floatValue;\nreturn msg;*/\n\n\nmsg.payload = Number(msg.payload);\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":980,"y":200,"wires":[["8095f328.b0aa7"]]},{"id":"dfaa887.1429078","type":"ui_group","z":"","name":"chart","tab":"8e6de17b.7c4dc","order":1,"disp":true,"width":"6","collapse":false},{"id":"565085c1.c65bcc","type":"MSSQL-CN","z":"","name":"DatabasePlenion","server":"10.100.0.100","encyption":true,"database":"PlenionData"},{"id":"8e6de17b.7c4dc","type":"ui_tab","z":"","name":"Dashboard Silicon","icon":"description","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [9 October 2020 09:17 UTC](https://discourse.nodered.org/t/how-to-get-a-number-on-my-dasboard-instead-of-a-string/33978/10 "2020-10-09T09:17:34Z")

</div>

The data from your database request is an array, containing one object but is formatted kind of bad way.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/5/8581e984231b846e9652fe4ba07965f1190b689a.png)

Object key is empty string.

You can get the value of course even if it is that strange formatted.

With function node you can parse the value like this.

```auto
msg.payload = msg.payload[0][""]
return msg;

```

But that data formatting looks to me bad enough. So maybe you can figure out why it is formatted that way.

---

<div class="post-metadata">

**Author:** ![iTzBrilliiiant](https://avatars.discourse-cdn.com/v4/letter/i/2acd7d/32.png) [@iTzBrilliiiant](https://discourse.nodered.org/u/iTzBrilliiiant)\
**Post date:** [9 October 2020 09:22 UTC](https://discourse.nodered.org/t/how-to-get-a-number-on-my-dasboard-instead-of-a-string/33978/11 "2020-10-09T09:22:08Z")

</div>

Thanks! This is what i needed, yeah the data is formatted bad because in my query i use a count.

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [9 October 2020 14:06 UTC](https://discourse.nodered.org/t/how-to-get-a-number-on-my-dasboard-instead-of-a-string/33978/12 "2020-10-09T14:06:35Z")

</div>

Of course in a function node... you could always use the Javascript Number() function to actually convert a string to a numeric valve. Just say this for reference. But in this case, the issue was bit more involved. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 October 2020 14:06 UTC](https://discourse.nodered.org/t/how-to-get-a-number-on-my-dasboard-instead-of-a-string/33978/13 "2020-10-23T14:06:36Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
