# JSONATA - Lookup data in a change node?

**URL:** <https://discourse.nodered.org/t/jsonata-lookup-data-in-a-change-node/50614>\
**Category:** General\
**Created:** [4 September 2021 17:14 UTC](https://discourse.nodered.org/t/jsonata-lookup-data-in-a-change-node/50614 "2021-09-04T17:14:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [4 September 2021 17:14 UTC](https://discourse.nodered.org/t/jsonata-lookup-data-in-a-change-node/50614/1 "2021-09-04T17:14:27Z")

</div>

Guys,

My inverter sends in a heap of data which i am parsing with the Buffer Parser node - one of those variables is battery mode - which comes in as a number - mode 1 = charging, mode 2 = discharging

I am currently using a change node to set this (and other things as global variables for use throughout my flows.

Is there a way to take that incoming stream and on the fly convert that from Mode 1 to Mode Charging and store that in the Global varisable instead ?

This way when i populate my dashboard i have it there rather than using a function node to look it up and change it

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/4/b4622921864e6bf1ec13b94a1b52008a197e479a.png)

And then when i put it on the dashboard i use the text node

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/c/0c74dbf2869ef5caffc35c0f78cd70098503e56f.png)

Which means i need another change node before the Dashboard Text node

Craig

---

<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:** [4 September 2021 17:34 UTC](https://discourse.nodered.org/t/jsonata-lookup-data-in-a-change-node/50614/2 "2021-09-04T17:34:09Z")

</div>

Try a ternary expression

```auto
$$.payload.battery_mode = 1 ? "Charging" : 
$$.payload.battery_mode = 2 ? "Discharging" : "Error"

```

> **[Other Operators · JSONata](https://docs.jsonata.org/other-operators#--conditional)**
>
> \## \`&\` (Concatenation)

[edit corrected missing payload property]

---

<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:** [18 September 2021 17:34 UTC](https://discourse.nodered.org/t/jsonata-lookup-data-in-a-change-node/50614/3 "2021-09-18T17:34:10Z")

</div>

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