# Script to lookup a dataset tag and bring corresponding column values?

**URL:** <https://forum.inductiveautomation.com/t/script-to-lookup-a-dataset-tag-and-bring-corresponding-column-values/45580>\
**Category:** Ignition\
**Tags:** ignition81, perspective, scripting, ignition80\
**Created:** [April 14, 2021, 10:55am UTC](https://forum.inductiveautomation.com/t/script-to-lookup-a-dataset-tag-and-bring-corresponding-column-values/45580 "2021-04-14T10:55:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![berkay.cinar](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@berkay.cinar](https://forum.inductiveautomation.com/u/berkay.cinar)\
**Post date:** [April 14, 2021, 10:55am UTC](https://forum.inductiveautomation.com/t/script-to-lookup-a-dataset-tag-and-bring-corresponding-column-values/45580/1 "2021-04-14T10:55:25Z")

</div>

Hello I want to create a memory dataset tag which includes all desired info and want to have a script that looks for the value and brings corresponding desired column result for that value. I tried this;

OPName=lookup("[.]Dataset2",“1”,“Hata”,0,2)  
system.tag.write("[.]CabinID",OPName).value

Dataset2 is a memory dataset tag

This is resulting an error like this;

Error executing script.  
Traceback (most recent call last):  
File “tagevent:valueChanged”, line 2, in valueChanged  
NameError: global name ‘lookup’ is not defined

Could anyone help me with a code to achieve this.

BR,  
Berkay

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 14, 2021, 11:26am UTC](https://forum.inductiveautomation.com/t/script-to-lookup-a-dataset-tag-and-bring-corresponding-column-values/45580/2 "2021-04-14T11:26:54Z")

</div>

You’re mixing the expression language and jython.

To read the value of a tag you need to use `system.tag.readBlocking()`.

That will return a list of qualified values, so you will also want to pull the value from that. Since your tag is a dataset tag, you will get the whole dataset returned. Code will look something like

```auto
ds = system.tag.readBlocking(["[.]Dataset2"])[0].value
OPname = ds.getValueAt(1,'Hata')

```

---

<div class="post-metadata">

**Author:** ![berkay.cinar](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@berkay.cinar](https://forum.inductiveautomation.com/u/berkay.cinar)\
**Post date:** [April 14, 2021, 4:34pm UTC](https://forum.inductiveautomation.com/t/script-to-lookup-a-dataset-tag-and-bring-corresponding-column-values/45580/3 "2021-04-14T16:34:20Z")

</div>

I am trying to use ignitions expression function lookup.It is I think the most convinient way of doing what I want. This is basically like an excel vlookup which is exactly what I want. I see this on the ignition manuel here;

[https://docs.inductiveautomation.com/display/DOC79/lookup](https://docs.inductiveautomation.com/display/DOC79/lookup)

Even though I try to use the same code in the link I keep getting lookup is not defined error do I need to import a library first? how to define it?

Please help here

Thanks

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 14, 2021, 5:03pm UTC](https://forum.inductiveautomation.com/t/script-to-lookup-a-dataset-tag-and-bring-corresponding-column-values/45580/4 "2021-04-14T17:03:09Z")

</div>

You can’t use expression functions in jython scripts. Use an expression binding or an expression tag to use any expression function.

---

<div class="post-metadata">

**Author:** ![berkay.cinar](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@berkay.cinar](https://forum.inductiveautomation.com/u/berkay.cinar)\
**Post date:** [April 14, 2021, 8:33pm UTC](https://forum.inductiveautomation.com/t/script-to-lookup-a-dataset-tag-and-bring-corresponding-column-values/45580/5 "2021-04-14T20:33:35Z")

</div>

Thanks have not realized the expression bindings before really helpfull, got it to work what I need
