# Help please with directing string arrays to different dashboard elements

**URL:** <https://discourse.nodered.org/t/help-please-with-directing-string-arrays-to-different-dashboard-elements/4006>\
**Category:** Dashboard\
**Created:** [15 October 2018 20:11 UTC](https://discourse.nodered.org/t/help-please-with-directing-string-arrays-to-different-dashboard-elements/4006 "2018-10-15T20:11:42Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![cliffpza](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@cliffpza](https://discourse.nodered.org/u/cliffpza)\
**Post date:** [15 October 2018 20:11 UTC](https://discourse.nodered.org/t/help-please-with-directing-string-arrays-to-different-dashboard-elements/4006/1 "2018-10-15T20:11:42Z")

</div>

I am getting data from an electricity current meter where the amps values are coming in as msg.payload: string[7] and kwh as msg.payload: string[6]  
the data comes in as one stream of data from my arduino alternating between the two

i want the string[7] values to go to a gauge and the string [6] values to a text item on the dashboard

i am ok with the dashboard itself but i need to know how to direct the streams of data as above please

i have looked at the Switch node which is where i thought it would be quite straight forward but i dont see anything there that is logically the answer

please help

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [15 October 2018 20:21 UTC](https://discourse.nodered.org/t/help-please-with-directing-string-arrays-to-different-dashboard-elements/4006/2 "2018-10-15T20:21:28Z")

</div>

Hi @cliffpza

if you know for sure the two different strings are consistently those different lengths, then you can configure a Switch node to check the length of msg.payload using a JSONata expression:

 ![Local_Node-RED](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/246ea8e5f513430b379eb5b96965f912d39df871.png)

```auto
[{"id":"bb4089dc.98ca68","type":"switch","z":"24d928f3.3c58f8","name":"","property":"$length(payload)","propertyType":"jsonata","rules":[{"t":"eq","v":"6","vt":"num"},{"t":"eq","v":"7","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":630,"y":60,"wires":[["4fc09522.6f4eec"],["62b0d077.07658"]]}]

```

---

<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:** [15 October 2018 20:26 UTC](https://discourse.nodered.org/t/help-please-with-directing-string-arrays-to-different-dashboard-elements/4006/3 "2018-10-15T20:26:51Z")

</div>

The second one should probably be number 7 not string 7 too. It might work either way.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [15 October 2018 20:27 UTC](https://discourse.nodered.org/t/help-please-with-directing-string-arrays-to-different-dashboard-elements/4006/4 "2018-10-15T20:27:47Z")

</div>

> [@Colin](#):
>
> The second one should probably be number 7 not string 7 too. It might work either way.

Oops - but yes, it does work even with that as I had tested it before sharing 🙂

---

<div class="post-metadata">

**Author:** ![cliffpza](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@cliffpza](https://discourse.nodered.org/u/cliffpza)\
**Post date:** [15 October 2018 20:33 UTC](https://discourse.nodered.org/t/help-please-with-directing-string-arrays-to-different-dashboard-elements/4006/5 "2018-10-15T20:33:59Z")

</div>

Hi @knolleary Thank you very much for your rapid reply.

Sorry i was not clear enough, the issue is not about the length of text but the fact that the data is in two different array elements called msg.payload : string[6] and msg.payload : string[7]  
i want these to go to different dashboard nodes based on which array element it is

i need a nodered function that will recognise which array element it is and direct it accordingly

---

<div class="post-metadata">

**Author:** ![cliffpza](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@cliffpza](https://discourse.nodered.org/u/cliffpza)\
**Post date:** [15 October 2018 20:35 UTC](https://discourse.nodered.org/t/help-please-with-directing-string-arrays-to-different-dashboard-elements/4006/6 "2018-10-15T20:35:16Z")

</div>

@Colin - thanks for reply, please see my clarification

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [15 October 2018 20:50 UTC](https://discourse.nodered.org/t/help-please-with-directing-string-arrays-to-different-dashboard-elements/4006/7 "2018-10-15T20:50:37Z")

</div>

Hi @cliffpza - that doesn't actually make it clearer. I'm not sure what `msg.payload : string[6]` means then if not a 6-character string.

Perhaps you could show some specific examples?

---

<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:** [15 October 2018 20:57 UTC](https://discourse.nodered.org/t/help-please-with-directing-string-arrays-to-different-dashboard-elements/4006/8 "2018-10-15T20:57:14Z")

</div>

> [@cliffpza](#):
>
> msg.payload : string[7]

Do you mean that msg.payload is an array and you want elements 6 and 7? If so then send it down two wires to two Change nodes one configured to Set msg.payload To msg.payload[6] and the other to Set msg.payload To msg.payload[7]. Then send the outputs of the two Change nodes to the dashboard nodes.

---

<div class="post-metadata">

**Author:** ![cliffpza](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@cliffpza](https://discourse.nodered.org/u/cliffpza)\
**Post date:** [16 October 2018 07:50 UTC](https://discourse.nodered.org/t/help-please-with-directing-string-arrays-to-different-dashboard-elements/4006/9 "2018-10-16T07:50:31Z")

</div>

Hi Colin, thank you very much!

---

<div class="post-metadata">

**Author:** ![cliffpza](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@cliffpza](https://discourse.nodered.org/u/cliffpza)\
**Post date:** [16 October 2018 09:16 UTC](https://discourse.nodered.org/t/help-please-with-directing-string-arrays-to-different-dashboard-elements/4006/10 "2018-10-16T09:16:51Z")

</div>

Hi @knolleary i think you are right! the string[] seems to refer to the length of the string - apologies  
What i am getting is in fact string[\*] where \* = variances depending on string length  
I will have to tag my data so i can separate it differenty

---

<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:** [16 October 2018 15:43 UTC](https://discourse.nodered.org/t/help-please-with-directing-string-arrays-to-different-dashboard-elements/4006/11 "2018-10-16T15:43:50Z")

</div>

> [@cliffpza](#):
>
> I will have to tag my data so i can separate it differenty

If you have control over the data format you could send it as json strings, then decoding will be simple.

---

<div class="post-metadata">

**Author:** ![cliffpza](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@cliffpza](https://discourse.nodered.org/u/cliffpza)\
**Post date:** [17 October 2018 09:45 UTC](https://discourse.nodered.org/t/help-please-with-directing-string-arrays-to-different-dashboard-elements/4006/12 "2018-10-17T09:45:09Z")

</div>

Hi Colin

Thank you. I tagged the data and was able to filter as needed. Your advice is much appreciated

Regards

Cliff

Using [Outlook](https://aka.ms/qtex0l) for iPhone 8
