# Searching a dataset through expression

**URL:** <https://forum.inductiveautomation.com/t/searching-a-dataset-through-expression/28816>\
**Category:** Ignition\
**Created:** [October 4, 2019, 3:15am UTC](https://forum.inductiveautomation.com/t/searching-a-dataset-through-expression/28816 "2019-10-04T03:15:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpavlicek](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rpavlicek/32/55868_2.png) [@rpavlicek](https://forum.inductiveautomation.com/u/rpavlicek)\
**Post date:** [October 4, 2019, 3:15am UTC](https://forum.inductiveautomation.com/t/searching-a-dataset-through-expression/28816/1 "2019-10-04T03:15:37Z")

</div>

Is it possible to search inside a dataset using the expression language?

We set a client tag to create a dataset through a SQL query, then create a custom property to the client tag. The dataset can have anywhere from 1 to 4 rows depending on a selection we make. So we don’t always know how many rows it will have and doing a {Root container.dataset}[row, column] isn’t always going to be the same. I almost though the lookup function would work, but seems it only works for table data…, unless we set the dataset to a Table. Is there any other ways to do this?

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [October 4, 2019, 3:59am UTC](https://forum.inductiveautomation.com/t/searching-a-dataset-through-expression/28816/2 "2019-10-04T03:59:45Z")

</div>

The [lookup](https://docs.inductiveautomation.com/display/DOC80/lookup) expression should work on any value of type `DataSet`:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/6/657e70a44099624354391c8f0d4e31cc857c9902.png)

Here’s the lookup expression in `_testDatsetLookup` tag:

```python
lookup({[.]_testDataset}, 1, '.', 'id', 'value')

```

---

<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:** [October 4, 2019, 12:12pm UTC](https://forum.inductiveautomation.com/t/searching-a-dataset-through-expression/28816/3 "2019-10-04T12:12:19Z")

</div>

If you want the entire selected row, or need to compare more than one column to find the desired row, you can use the [view() expression function](https://www.automation-pros.com/simaids/doc/expression.view.html) from my [Simulation Aids module](https://inductiveautomation.com/moduleshowcase/module/automation-professionals-llc-simulation-aids) (free). You’d use it like so:

```auto
view("Select * Where some_column==args[0] and some_other_column==args[1]",
  {Root Container.SourceDatasetProp},
  {Root Container.MatchSome},
  {Root Container.MatchSomeOther})

```

---

<div class="post-metadata">

**Author:** ![rpavlicek](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rpavlicek/32/55868_2.png) [@rpavlicek](https://forum.inductiveautomation.com/u/rpavlicek)\
**Post date:** [October 7, 2019, 4:53pm UTC](https://forum.inductiveautomation.com/t/searching-a-dataset-through-expression/28816/4 "2019-10-07T16:53:18Z")

</div>

Thank you to both for the solutions.

@witman’s idea was what I was trying and looking for, but didn’t get it to work before I asked this question, but I did get it to work now. Must have been syntax or something.

@pturmel - Thanks for the great contribution, will definitely be using more datasets in the future and your module looks great.
