# Typed input for gauge prefix and suffix

**URL:** <https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223>\
**Category:** General\
**Tags:** dashboard-2\
**Created:** [23 November 2026 13:44 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223 "2026-11-23T13:44:57Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [23 November 2026 13:44 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223/1 "2026-11-23T13:44:57Z")

</div>

This is a straightforward gauge which displays a numeric value (It's one of the figures from Mosquitto's `$SYS/broker/load/#` topic).

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/3/936e5a4f276404cb3994fd84812d93074c0ddf09.png)

AI gave me a Jsonata expression for the Value field typed input to convert it to GB, MB or kB and round the value to 1dp, though I could equally have done this with a function node.

```auto
(
  $n := $number(payload);
  $n >= 1000000000 ? $string($round($n / 1000000000, 1)) & " GB" :
  $n >= 1000000 ? $string($round($n / 1000000, 1)) & " MB" :
  $n >= 1000 ? $string($round($n / 1000, 1)) & " kB" :
  $string($round($n)) & " Byte"
)

```

With this, the value is shown in the required format, but the pointer is no longer shown (because payload is no longer a number)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/8/4807f5338372e2cfe6abcf00026817b1aceceff0.png)

There are Prefix and Suffix fields which can show static text eg `R$ 308.1 / barrel` but they are no use in my instance where the suffix can change.

If the prefix and suffix config were typed inputs (I think that's the right word) the suffix could be dynamically varied using a similar jsonata expression.

ps I do not have any expectation of this actually happening, so I'd be open to a Uibuilder snippet to achieve the same, or even something for the beautiful new offering from @smithtek 🙃

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [23 November 2026 14:11 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223/2 "2026-11-23T14:11:23Z")

</div>

According to the help you can use msg.ui\_update.suffix to set the suffix dynamically. You should be able to set that in the same message that sets the value.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [23 November 2026 14:41 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223/3 "2026-11-23T14:41:52Z")

</div>

Hmm I'd forgotten about msg.ui\_update. Thanks for reminding me.

It does work, but at the cost of needing an external function or change node.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/f/bf86a1a8cd4212793d777e491497925f4530d1bf.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [23 November 2026 14:56 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223/4 "2026-11-23T14:56:43Z")

</div>

If you pass in a fixed string of, say, "111.5 kB" does it draw the pointer? If so then I think then what you had originally should work. The fix may well just be a matter of using `Number()` on the result of the JSONata to get it back to a number for the pointer.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [23 November 2026 15:02 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223/5 "2026-11-23T15:02:09Z")

</div>

> [@jbudd](#):
>
> With this, the value is shown in the required format, but the pointer is no longer shown (because payload is no longer a number)
> 
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/8/4807f5338372e2cfe6abcf00026817b1aceceff0.png)

Have you checked that the reason the pointer is not shown is that the value is effectively zero in the range 0 to 100000 and you have set the style to rounded?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [23 November 2026 15:14 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223/6 "2026-11-23T15:14:47Z")

</div>

> [@Colin](#):
>
> Have you checked that the reason the pointer

Well yes I thought I had, but I seem to have so comprehensively failed to think for myself after consulting chatgpt that I'm no longer sure.

I am investigating again, as time permits.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [23 November 2026 16:59 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223/7 "2026-11-23T16:59:44Z")

</div>

OK...

If msg.payload has leading spaces, a number and trailing spaces, no suffix or jiggery-pokery, it works.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/6/86693e08999921f485fe21ea669bef5baf189a84.png)

But if it has other alphabetic characters, the pointer is not drawn.

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

Using the AI supplied jsonata, the pointer is not drawn.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/d/3dbb93619d03c9fa7d9ccd65bc457645c47d36fc.png)

Using jsonata in a change node to scale the value of payload and set msg.ui\_update.suffix works

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

So this flow will display about every 10 sec, bytes/min received by the MQTT broker, reformatted.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/optimized/3X/1/e/1e9e34621985ee25d9800cee5d69871aab6ba8e7_2_690x54.png)

```auto
[{"id":"519c118ad452e2c5","type":"mqtt in","z":"afeebe5db90fb807","name":"","topic":"$SYS/broker/load/bytes/received/1min","qos":"2","datatype":"auto-detect","broker":"754230cc.99c44","nl":false,"rap":true,"rh":0,"inputs":0,"x":170,"y":360,"wires":[["1cfb78c450b99bc4"]]},{"id":"1cfb78c450b99bc4","type":"change","z":"afeebe5db90fb807","name":"","rules":[{"t":"set","p":"ui_update.label","pt":"msg","to":"\"MQTT \" & (\t $n := $number(payload);\t $n >= 1000000000 ? \" GB received/min\" :\t $n >= 1000000 ? \" MB received/min\" :\t $n >= 1000 ? \" kB received/min\" :\t \" Bytes received/min\"\t)","tot":"jsonata"},{"t":"set","p":"ui_update.suffix","pt":"msg","to":"(\t $n := $number(payload);\t $n >= 1000000000 ? \" GB\" :\t $n >= 1000000 ? \" MB\" :\t $n >= 1000 ? \" kB\" :\t \" Byte\"\t)","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"(\t $n := $number(payload);\t $n >= 1000000000 ? $round($n / 1000000000, 1) :\t $n >= 1000000 ? $round($n / 1000000, 1) :\t $n >= 1000 ? $round($n / 1000, 1) :\t $round($n)\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":360,"wires":[["3b84235e4c6906ba"]]},{"id":"3b84235e4c6906ba","type":"ui-gauge","z":"afeebe5db90fb807","name":"Bytes Per Minute","group":"236e5ca0aaa8418f","order":0,"value":"payload","valueType":"msg","width":3,"height":3,"gtype":"gauge-half","gstyle":"needle","title":"msg.ui_update","alwaysShowTitle":false,"floatingTitlePosition":"top-left","units":"","icon":"","prefix":"","suffix":"","segments":[{"from":"0","color":"#5cd65c","text":"","textType":"label"}],"min":0,"max":"1000","sizeThickness":16,"sizeGap":4,"sizeKeyThickness":8,"styleRounded":true,"styleGlow":false,"className":"","x":650,"y":360,"wires":[[]]},{"id":"754230cc.99c44","type":"mqtt-broker","name":"","broker":"glasspi","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"test/mqtt/birth","birthQos":"0","birthRetain":"false","birthPayload":"Connected to mosquitto","birthMsg":{},"closeTopic":"test/mqtt/death","closeQos":"0","closeRetain":"false","closePayload":"Disconnecting mosquitto","closeMsg":{},"willTopic":"test/mqtt/lwt","willQos":"0","willRetain":"false","willPayload":"Mosquitto disconnected","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"236e5ca0aaa8418f","type":"ui-group","name":"Gauges","page":"01d2de3edc523d42","width":6,"height":1,"order":-1,"showTitle":false,"className":"","visible":"true","disabled":"false","groupType":"default","keepLoaded":false,"tab":""},{"id":"01d2de3edc523d42","type":"ui-page","name":"mqtt","ui":"a3e614cd9df4ae2e","path":"/mqtt","icon":"home","layout":"grid","theme":"0d92c765bfad87e6","breakpoints":[{"name":"Default","px":"0","cols":"3"},{"name":"Tablet","px":"576","cols":"6"},{"name":"Small Desktop","px":"768","cols":"9"},{"name":"Desktop","px":"1024","cols":"12"}],"tabs":[],"order":-1,"className":"","visible":"true","disabled":"false"},{"id":"a3e614cd9df4ae2e","type":"ui-base","name":"My Dashboard","path":"/dashboard","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control"],"showPathInSidebar":false,"navigationStyle":"default","titleBarStyle":"default"},{"id":"0d92c765bfad87e6","type":"ui-theme","name":"Basic Blue Theme","colors":{"surface":"#4d58ff","primary":"#0094ce","bgPage":"#eeeeee","groupBg":"#ffffff","groupOutline":"#cccccc"},"sizes":{"pagePadding":"12px","groupGap":"12px","groupBorderRadius":"4px","widgetGap":"12px","density":"comfortable"}},{"id":"81096b376717ca84","type":"global-config","env":[],"modules":{"@flowfuse/node-red-dashboard":"1.37.0"}}]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/e/be4ef4705083ad72c3d1ccdbc7831703e0a4f387.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [23 November 2026 17:07 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223/8 "2026-11-23T17:07:50Z")

</div>

Sorry, yes, you had already answered that.

I am surprised at that, I would have expected the code to convert the string to a number using `Number()` which I think should work ok.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [23 November 2026 17:24 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223/9 "2026-11-23T17:24:43Z")

</div>

> [@jbudd](#):
>
> if it has other alphabetic characters, the pointer is not drawn.

That is covered by the example above, but just to check I tried the original JSONATA in a change node and no msg.ui\_update. There is no pointer.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [23 November 2026 17:27 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223/10 "2026-11-23T17:27:35Z")

</div>

Sorry, yes, you had already answered that.

I am surprised at that, I would have expected the code to convert the string to a number using `Number()` which I think should work ok.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [23 November 2026 17:52 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223/11 "2026-11-23T17:52:07Z")

</div>

There is a complex calculation going on to convert the input value into an SVG path so yes, it's a bit surprising the payload is not cast to a number first.

While playing with these gauges, switching backwards and forwards between Jsonata and msg.payload, it occurred to me that perhaps we could dispense with the msg.... option in typed inputs in general, instead defaulting to jsonata?

For the way eg a debug node works now, defaulting to msg.payload, we _might not_ have to learn any jsonata syntax because jsonata syntax for message properties is the same as msg.blah.blah syntax.

eg given

```auto
[{"reactor":1,"core":{"temp":1855,"pressure":88.88}},{"number":2,"core":{"temp":408,"pressure":27}}]

```

`msg.payload[1].core.temp` and jsonata `payload[1].core.temp` _both evaluate to 408_

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [23 November 2026 21:20 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223/12 "2026-11-23T21:20:04Z")

</div>

> [@jbudd](#):
>
> we _might not_ have to learn any jsonata syntax

We don't have to learn any jsonata syntax as things are already. I very rarely use jsonata.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [23 November 2026 22:07 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223/13 "2026-11-23T22:07:45Z")

</div>

> [@jbudd](#):
>
> While playing with these gauges, switching backwards and forwards between Jsonata and msg.payload, it occurred to me that perhaps we could dispense with the msg.... option in typed inputs in general, instead defaulting to jsonata?

No! Please no!!

JSONata is massive overkill for a lot (most?) use-cases. It is comparatively slow and complex. And lots of things _will_ break if typed inputs were changed this way.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [23 November 2026 23:18 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223/14 "2026-11-23T23:18:39Z")

</div>

I think perhaps you are evading what I was idly pondering.

Imagine a config field  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/d/ddcbc175f51bf847f36804ef032b371ddc4a64f8.png)

And you could, if you wanted, enter in that field  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/7/27c4dc248375185eaeac4f1ac1bf423e1a6cf4f6.png)

Or for an input  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/3/2371b654a789cc58c8eff1da057060c5ccf9aeb9.png)

Now imagine that Node-red, without you having to select the big scary `J:` option, transparently evaluated the Jsonata expression.

> [@TotallyInformation](#):
>
> JSONata is ... comparatively slow

Yes. It's always much slower to invoke a general purpose software tool than a single purpose one.  
I think evaluating a simple jsonata expression takes at least 10 times as long as evaluating the same expression in javascript

> [@TotallyInformation](#):
>
> and complex.

Some expressions are complex. Here are a couple of jsonata expressions which are not:  
payload  
payload.count / 3

> [@TotallyInformation](#):
>
> lots of things _will_ break

This is precisely what I wondered.  
What kind of valid msg.blah input in a config node would break if it was evaluated as jsonata?  
There may be many examples; I demonstrated above that msg.payload[1].core.temp is not one (Ignoring that jsonata does not accept the `msg.`]

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [23 November 2026 23:44 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223/15 "2026-11-23T23:44:33Z")

</div>

> [@jbudd](#):
>
> Some expressions are complex. Here are a couple of jsonata expressions which are not:  
> payload

While true, the fact is that you've had to evaluate via a very large and complex library. The startup time for JSONata evaluation is significant. For any flow that needs to process things efficiently, JSONata is not (ever?) the way to go.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [24 November 2026 00:00 UTC](https://discourse.nodered.org/t/typed-input-for-gauge-prefix-and-suffix/102223/16 "2026-11-24T00:00:04Z")

</div>

> [@TotallyInformation](#):
>
> the fact is that you've had to evaluate via a very large and complex library.

A flexible input method would probably check if it parsed correctly as a message property before invoking any external libraries.  
A smaller delay but still a delay.

I thought I had acknowledged your point about jsonata being less efficient.

Some might say for any program that needs to process things efficiently, Node-red is not (ever?) the way to go.  
All depends on your value of "efficiently".
