# link to the last entry of the source table

**URL:** <https://forum.kx.com/t/link-to-the-last-entry-of-the-source-table/7968>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [October 16, 2012, 6:13pm UTC](https://forum.kx.com/t/link-to-the-last-entry-of-the-source-table/7968 "2012-10-16T18:13:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sam11](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@Sam11](https://forum.kx.com/u/Sam11)\
**Post date:** [October 16, 2012, 6:13pm UTC](https://forum.kx.com/t/link-to-the-last-entry-of-the-source-table/7968/1 "2012-10-16T18:13:00Z")

</div>

Link columns by default link to the first entry of the column in the source table. But is it possible to change this such that it links to the last&nbsp;occurrence. I’ve a scenario where I have a time series and I need to link to the most recent update. Note that these tables are fairly big and memory mapped, so sorting a table would not be a viable option.

e.g.

q)t1:( c1:`sym?`c`b`a`c; c2: 10 20 30 40)

q)t1

c1 c2

* * *

**c 10**

b &nbsp;20

a &nbsp;30

**c 40**

q)show t2:( c3:`sym?`a`b`a`c; c4: 1. 2. 3. 4.)

c3 c4

* * *

a &nbsp;1

b &nbsp;2

a &nbsp;3

**c 4**

q)select `t1!t1.c1?c3 &nbsp; from t2

2

1

2

**0**

I need the last entry above to be 3.

thanks

---

<div class="post-metadata">

**Author:** ![Attila](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@Attila](https://forum.kx.com/u/Attila)\
**Post date:** [October 16, 2012, 6:55pm UTC](https://forum.kx.com/t/link-to-the-last-entry-of-the-source-table/7968/2 "2012-10-16T18:55:00Z")

</div>



---

<div class="post-metadata">

**Author:** ![abcfoots1](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@abcfoots1](https://forum.kx.com/u/abcfoots1)\
**Post date:** [October 16, 2012, 8:38pm UTC](https://forum.kx.com/t/link-to-the-last-entry-of-the-source-table/7968/3 "2012-10-16T20:38:00Z")

</div>

d:(!). value each(first;last)@':group t1.c1

update tlink:`t1!d[t1.c1?c3] from `t2

---

<div class="post-metadata">

**Author:** ![Sam11](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@Sam11](https://forum.kx.com/u/Sam11)\
**Post date:** [October 16, 2012, 9:43pm UTC](https://forum.kx.com/t/link-to-the-last-entry-of-the-source-table/7968/4 "2012-10-16T21:43:00Z")

</div>

Thanks. There is a small mistake (as t1 and t2 might not have same #rows)

select`t1!count\*\*[t1]-\*\*1+reverse[t1.c1]?c3 from t2
