JSONata - $round

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

thanks

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:

            [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])]

hello

Thanks, yes i want to leave the nulls

Thanks a lot

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