# JSONata - $round

**URL:** https://discourse.nodered.org/t/jsonata-round/24966
**Category:** General
**Created:** [16 April 2020 19:06 UTC](https://discourse.nodered.org/t/jsonata-round/24966 "2020-04-16T19:06:45Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Cristiano](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@Cristiano](https://discourse.nodered.org/u/Cristiano)
#### Post date: [16 April 2020 19:06 UTC](https://discourse.nodered.org/t/jsonata-round/24966/1 "2020-04-16T19:06:45Z")

</div>

Hello,

I am usinga double query to the influx and I receive two arrays with the values ​​of the two measurements, then convert to JSONata and show it in the chart. (4 values)

I am using the $ round function, for the values ​​in both arrays, for the first one it works well for the second arrays I have an error.

I leave the link: [https://try.jsonata.org/M6Gz1Fn7h](https://try.jsonata.org/M6Gz1Fn7h)

thanks

---

<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: [16 April 2020 19:35 UTC](https://discourse.nodered.org/t/jsonata-round/24966/2 "2020-04-16T19:35:52Z")

</div>

In your data, there are lots of instances where `$[3]` (and the others) evaluates to `null` - which `$round()` does not accept.

You need to decide what you want to do with the `null` values - do you want to keep them as `null` or do you want to insert a placeholder value?

The following expression will leave the nulls in place:

```auto
            [series[0].values.($boolean($[1])?$round($[1],2):$[1])],
            [series[0].values.($boolean($[2])?$round($[2],2):$[2])],
            [series[1].values.($boolean($[3])?$round($[3],2):$[3])],
            [series[1].values.($boolean($[4])?$round($[4],2):$[4])]

```

---

<div class="post-metadata">

### Author: ![Cristiano](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@Cristiano](https://discourse.nodered.org/u/Cristiano)
#### Post date: [17 April 2020 00:04 UTC](https://discourse.nodered.org/t/jsonata-round/24966/3 "2020-04-17T00:04:54Z")

</div>

hello

Thanks, yes i want to leave the nulls

Thanks a lot

---

<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: [1 May 2020 00:04 UTC](https://discourse.nodered.org/t/jsonata-round/24966/4 "2020-05-01T00:04:54Z")

</div>

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