# Calculations HTTP Request received data string

**URL:** <https://discourse.nodered.org/t/calculations-http-request-received-data-string/45679>\
**Category:** General\
**Created:** [15 May 2021 12:20 UTC](https://discourse.nodered.org/t/calculations-http-request-received-data-string/45679 "2021-05-15T12:20:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [15 May 2021 12:20 UTC](https://discourse.nodered.org/t/calculations-http-request-received-data-string/45679/1 "2021-05-15T12:20:02Z")

</div>

Because I have little experience with NodeRED, I run into a problem. With an HTTP Request I retrieve the data as in the graphic, a left column with 24 values and a right column with 24 times.

I want to add the first 3 values of the left column (green square) to be processed further. In the example, that value would be 154.

Can someone tell me how to do that?

```auto
[{"id":"a7ca5e83.ddd39","type":"tab","label":"Rain","disabled":false,"info":""},{"id":"566ef5f9.d235fc","type":"inject","z":"a7ca5e83.ddd39","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":100,"wires":[["9fc6992c.30f8a8"]]},{"id":"9fc6992c.30f8a8","type":"http request","z":"a7ca5e83.ddd39","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://gpsgadget.buienradar.nl/data/raintext?lat=51&lon=3","tls":"","persist":false,"proxy":"","authType":"basic","x":350,"y":100,"wires":[["85f8de99.1bb49"]]},{"id":"85f8de99.1bb49","type":"debug","z":"a7ca5e83.ddd39","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":100,"wires":[]}]

```

 ![forum](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/b/abf02419bb6a479d97221d01132a1c92d8fc900e.png)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [15 May 2021 12:48 UTC](https://discourse.nodered.org/t/calculations-http-request-received-data-string/45679/2 "2021-05-15T12:48:56Z")

</div>

There are multiple ways to do this, you could run the string throug a cvs node to convert to an array of objects then use Javascript or JSONata to sum the first 3 array values.  
e.g.

```auto
[{"id":"566ef5f9.d235fc","type":"inject","z":"a7ca5e83.ddd39","name":"","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":80,"wires":[["e9b1d32a.56ac38"]]},{"id":"e9b1d32a.56ac38","type":"template","z":"a7ca5e83.ddd39","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"000|14:05\n077|14:10\n077|14:15\n092|14:20\n092|14:25","output":"str","x":250,"y":80,"wires":[["776da0a1.f6fc"]]},{"id":"776da0a1.f6fc","type":"csv","z":"a7ca5e83.ddd39","name":"","sep":"|","hdrin":"","hdrout":"none","multi":"mult","ret":"\\n","temp":"value,time","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":390,"y":80,"wires":[["25f6f6be.47474a"]]},{"id":"25f6f6be.47474a","type":"change","z":"a7ca5e83.ddd39","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$sum(payload[[0..2]].[$number(value)].*)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":140,"wires":[["85f8de99.1bb49"]]},{"id":"85f8de99.1bb49","type":"debug","z":"a7ca5e83.ddd39","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":140,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [15 May 2021 12:59 UTC](https://discourse.nodered.org/t/calculations-http-request-received-data-string/45679/3 "2021-05-15T12:59:30Z")

</div>

I could not have imagined that or it would have cost me a lot of time and frustration. That's why I'm very glad you helped me, thank you!

---

<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:** [29 May 2021 12:59 UTC](https://discourse.nodered.org/t/calculations-http-request-received-data-string/45679/4 "2021-05-29T12:59:44Z")

</div>

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