# Need help with extracting values in Function node

**URL:** <https://discourse.nodered.org/t/need-help-with-extracting-values-in-function-node/65837>\
**Category:** General\
**Created:** [31 July 2022 04:01 UTC](https://discourse.nodered.org/t/need-help-with-extracting-values-in-function-node/65837 "2022-07-31T04:01:14Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![LosinIt](https://avatars.discourse-cdn.com/v4/letter/l/439d5e/32.png) [@LosinIt](https://discourse.nodered.org/u/LosinIt)\
**Post date:** [1 August 2022 03:41 UTC](https://discourse.nodered.org/t/need-help-with-extracting-values-in-function-node/65837/21 "2022-08-01T03:41:11Z")

</div>

Many thanks to @Colin and @UnborN for "teaching me to fish"! 💜

---

<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:** [1 August 2022 07:12 UTC](https://discourse.nodered.org/t/need-help-with-extracting-values-in-function-node/65837/22 "2022-08-01T07:12:53Z")

</div>

I realise was confused about why you were using the Join node. I thought you wanted to put them all into one measurement, in which case you would end up with a payload something like

```auto
[
  {
    power: 25,
    volts: 230,
    power: 15.3,
    cumulative_power: 1234.4
  },
  {
    device: "1234",
  }
]

```

Which is fed into an Influx Out node.  
But it seems you are writing them to separate measurements, in which case there is definitely no need to use the join node. So I suggest taking that out and feeding all the incoming values into a simple function node which returns a message with `msg.measurement` set to the measurement determined from the topic, and a payload consisting of something like

```auto
{
  value: 25.75
},
{
  device: "1234",
}

```

So identical message contents for them all, the only difference is the measurement. No need to mess about using a Join node and then building the array in the function node.  
In addition, don't put the units and type as tags in the record, there is no point doing that and it doubles the amount of data in each record. For any measurement those should always be the same.

**[Edit]** and of course the function returns nothing if the value is not valid for some reason.

---

<div class="post-metadata">

**Author:** ![LosinIt](https://avatars.discourse-cdn.com/v4/letter/l/439d5e/32.png) [@LosinIt](https://discourse.nodered.org/u/LosinIt)\
**Post date:** [1 August 2022 13:10 UTC](https://discourse.nodered.org/t/need-help-with-extracting-values-in-function-node/65837/23 "2022-08-01T13:10:35Z")

</div>

🤣  
Oh, good grief! Just when I thought I had what I was after 🙄

Silly me didn't actually 👀 at individual records to verify what was there but it seems obvious now that you point it out. At least now I know how to rearrange things.

Thank you, @Colin

---

<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:** [15 August 2022 13:11 UTC](https://discourse.nodered.org/t/need-help-with-extracting-values-in-function-node/65837/24 "2022-08-15T13:11:24Z")

</div>

Closed on 15 August 2022 13:11 UTC

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

[Previous page](https://discourse.nodered.org/t/need-help-with-extracting-values-in-function-node/65837.md?page=1)
