# Selecting last row of a table

**URL:** <https://forum.inductiveautomation.com/t/selecting-last-row-of-a-table/5924>\
**Category:** Ignition\
**Created:** [February 25, 2013, 4:58pm UTC](https://forum.inductiveautomation.com/t/selecting-last-row-of-a-table/5924 "2013-02-25T16:58:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaepark](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jaepark](https://forum.inductiveautomation.com/u/jaepark)\
**Post date:** [February 25, 2013, 4:58pm UTC](https://forum.inductiveautomation.com/t/selecting-last-row-of-a-table/5924/1 "2013-02-25T16:58:55Z")

</div>

What is the best way to select the last row of a table and retrieve a value from it after a new row is added?  
I am currently using the following, which does select the last tow but the value retrieved is from the previous row.

The SelectedRow of the table is bound to  
len({Root Container.tblMults.data}) -1

I have a label that should display the MultID value of the last selected row.  
The text value is bound to:  
{Root Container.tblMults.data}[{Root Container.tblMults.selectedRow},‘MultID’]

It should also be able to select the last row after a row is deleted from the table

---

<div class="post-metadata">

**Author:** ![dave.fogle](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@dave.fogle](https://forum.inductiveautomation.com/u/dave.fogle)\
**Post date:** [February 27, 2013, 12:00am UTC](https://forum.inductiveautomation.com/t/selecting-last-row-of-a-table/5924/2 "2013-02-27T00:00:32Z")

</div>

Your expressions look about right to me. I made some slight modifications:

Expression on Selected Row:

```python
len({Root Container.tblMults.data})-1
```

Expression on text property of label:

```python
{Root Container.tblMults.data}[toInt(len({Root Container.tblMults.data})-1),"MultID"]
```

Give that a try and see if it works for you.

---

<div class="post-metadata">

**Author:** ![jaepark](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jaepark](https://forum.inductiveautomation.com/u/jaepark)\
**Post date:** [February 27, 2013, 2:43pm UTC](https://forum.inductiveautomation.com/t/selecting-last-row-of-a-table/5924/3 "2013-02-27T14:43:21Z")

</div>

Thank you that worked great.
