# Integration Toolkit Solutions Wiki

**URL:** <https://forum.inductiveautomation.com/t/integration-toolkit-solutions-wiki/105080>\
**Category:** 3rd Party Modules\
**Tags:** scripting, ignition81\
**Created:** [April 14, 2025, 9:02pm UTC](https://forum.inductiveautomation.com/t/integration-toolkit-solutions-wiki/105080 "2025-04-14T21:02:36Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [April 23, 2025, 6:07am UTC](https://forum.inductiveautomation.com/t/integration-toolkit-solutions-wiki/105080/12 "2025-04-23T06:07:40Z")

</div>

## Get the row index of a dataset/list matching criteria - Matches `lookup` function but returns row index

I want to replicate the functionality of `lookup(...)` except instead of returning a cell value, I want to return the index of the found row.

Wrap a `forEach()` inside `where()` to include the original index in the output.

> **Index Lookup**
>
> ```python
> where(
> forEach( // Expand the source into pairs of original index and content there
> {path.to.source},
> idx(),
> it()
> ),
> it()[1]['someColumn'] = 'SomeValue' // original content is the 2nd element of the pair
> )[0][0] // Extract first match, then original index is the 1st element of the pair
> 
> ```

Note that most applications that need the index need it to retrieve multiple parts of the found row. It is better to simply use `where()` to return the entire first matching result. { I want to use this for the `scrollIntoView` JS function which needs the row index }

If the source is sure to be a dataset, consider using `selectStar()` to add a new column holding the original index instead of making pairs. Something like this:

> **Dataset Row Lookup**
>
> ```python
> where(
> where(
> selectStar( // Expand the source to include an original index column
> {path.to.source.dataset},
> asMap('_original_idx', I),
> idx()
> ),
> it()['someColumn'] = 'SomeValue' // any ordinary condition
> ),
> idx() < 1 // Extract first row
> )
> 
> ```

> **Functions Used**
>
> - [where()](https://www.automation-pros.com/toolkit/doc/iteration.html#where)
> - [forEach()](https://www.automation-pros.com/toolkit/doc/iteration.html#foreach)
> - [idx()](https://www.automation-pros.com/toolkit/doc/iteration.html#idx)
> - [it()](https://www.automation-pros.com/toolkit/doc/iteration.html#it)
> - [selectStar()](https://www.automation-pros.com/toolkit/doc/datasets.html#selectstar)
> - [asMap()](https://www.automation-pros.com/toolkit/doc/iteration.html#asmap)

---

_[View the full topic](https://forum.inductiveautomation.com/t/integration-toolkit-solutions-wiki/105080)._
