# How do I use a variable in an object path with JSONata

**URL:** <https://discourse.nodered.org/t/how-do-i-use-a-variable-in-an-object-path-with-jsonata/16283>\
**Category:** General\
**Created:** [3 October 2019 21:18 UTC](https://discourse.nodered.org/t/how-do-i-use-a-variable-in-an-object-path-with-jsonata/16283 "2019-10-03T21:18:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jamie](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@Jamie](https://discourse.nodered.org/u/Jamie)\
**Post date:** [3 October 2019 21:18 UTC](https://discourse.nodered.org/t/how-do-i-use-a-variable-in-an-object-path-with-jsonata/16283/1 "2019-10-03T21:18:23Z")

</div>

I'm using the code below in a Change Node using JSONata to structure MySQL data to send to a graph node. Is there any way for me to add the column name into the object path from a flow variable?

[  
{  
"series": ["B"],  
"labels": [payload.time],  
"data": [[payload.AvgAirTemp1]]  
}  
]

I've tried changing to the line below but it didn't work

"data": [[payload.$flowContext('columnName')]]

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:** [3 October 2019 21:21 UTC](https://discourse.nodered.org/t/how-do-i-use-a-variable-in-an-object-path-with-jsonata/16283/2 "2019-10-03T21:21:46Z")

</div>

Hi @Jamie

try:

```auto
"data": [[$lookup(payload,$flowContext('columnName'))]]

```

---

<div class="post-metadata">

**Author:** ![Jamie](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@Jamie](https://discourse.nodered.org/u/Jamie)\
**Post date:** [7 October 2019 12:36 UTC](https://discourse.nodered.org/t/how-do-i-use-a-variable-in-an-object-path-with-jsonata/16283/3 "2019-10-07T12:36:27Z")

</div>

Thank you. That is what I needed.
