# Return the second match for a VLOOKUP

**URL:** <https://community.glideapps.com/t/return-the-second-match-for-a-vlookup/1043>\
**Category:** Ask for Help\
**Created:** [October 9, 2019, 2:14pm UTC](https://community.glideapps.com/t/return-the-second-match-for-a-vlookup/1043 "2019-10-09T14:14:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sandro\_Brito](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/sandro_brito/32/552_2.png) [@Sandro\_Brito](https://community.glideapps.com/u/Sandro_Brito)\
**Post date:** [October 9, 2019, 2:14pm UTC](https://community.glideapps.com/t/return-the-second-match-for-a-vlookup/1043/1 "2019-10-09T14:14:39Z")

</div>

I am building an app where the same item can be sold multiple times, retaining it’s itemID. This is important because we want to be able to get a history of that item.

I have the following  
=ARRAYFORMULA(IF(LEN($A3:$A) = 0, “first”, IF(ISERROR(VLOOKUP($A3:$A, Sales!$A3:$A, 1, false)), “”, VLOOKUP($A3:$A, Sales!$A3:$C, 3, false)))) to assign a new owner. All it’s doing is looking at a table like this

itemID From To Price  
39 [prototype@email.com](mailto:prototype@email.com)[laura@email.com](mailto:laura@email.com) -10.00  
6 [prototype@email.com](mailto:prototype@email.com)[sandro@emai.com](mailto:sandro@emai.com) -10.00  
11 [prototype@email.com](mailto:prototype@email.com)[laura@email.com](mailto:laura@email.com) -10.00  
71 [prototype@email.com](mailto:prototype@email.com)[laura@email.com](mailto:laura@email.com) -10.00  
39 [laura@email.com](mailto:laura@email.com)[sandro@emai.com](mailto:sandro@emai.com) -25.00  
32 [prototype@email.com](mailto:prototype@email.com)[sandro@emai.com](mailto:sandro@emai.com) -10.00

The problem is that the formula trying to determine the current owner of the items but is only returning itemID 39 in its first instance.  
Item 39 has first been sold by the app to laura and then sold by laura to sandro.  
Yet the formula is only returning the email of the first transaction as the current owner.

I saw that with VLOOKUP you can turn to false and sometimes it returns the last entry but it doesn’t seem to work for mine.

Anyone knows how I can solve this?

---

<div class="post-metadata">

**Author:** ![Ralf](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf/32/492_2.png) [@Ralf](https://community.glideapps.com/u/Ralf)\
**Post date:** [October 9, 2019, 2:37pm UTC](https://community.glideapps.com/t/return-the-second-match-for-a-vlookup/1043/2 "2019-10-09T14:37:04Z")

</div>

Add a time stamp to the table, sort in reverse order, lookup last sold item which now is first in you table.

---

<div class="post-metadata">

**Author:** ![Sandro\_Brito](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/sandro_brito/32/552_2.png) [@Sandro\_Brito](https://community.glideapps.com/u/Sandro_Brito)\
**Post date:** [October 9, 2019, 2:42pm UTC](https://community.glideapps.com/t/return-the-second-match-for-a-vlookup/1043/3 "2019-10-09T14:42:20Z")

</div>

Hi Ralf,  
Thank you for your answer. Is there away that the time stamp is added automatically?  
The sales table is filled from a form in the glide app. Not sure how can I pass the time stamp from the app.

---

<div class="post-metadata">

**Author:** ![Ralf](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf/32/492_2.png) [@Ralf](https://community.glideapps.com/u/Ralf)\
**Post date:** [October 9, 2019, 2:57pm UTC](https://community.glideapps.com/t/return-the-second-match-for-a-vlookup/1043/4 "2019-10-09T14:57:40Z")

</div>

You can find the time stamp in the compnent list!

---

<div class="post-metadata">

**Author:** ![Sandro\_Brito](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/sandro_brito/32/552_2.png) [@Sandro\_Brito](https://community.glideapps.com/u/Sandro_Brito)\
**Post date:** [October 9, 2019, 3:07pm UTC](https://community.glideapps.com/t/return-the-second-match-for-a-vlookup/1043/5 "2019-10-09T15:07:44Z")

</div>

Hi Ralf, thank you so much.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [October 9, 2019, 3:37pm UTC](https://community.glideapps.com/t/return-the-second-match-for-a-vlookup/1043/6 "2019-10-09T15:37:45Z")

</div>

Take a look at [concepts.glideapp.io](http://concepts.glideapp.io)

Take a look at the sheet and copy the app to look at the Photo Choice example. The formula I use to set the users image looks for the last item on a list of form submissions. It’s a vlookup, but slightly different. The Currency Transfer/Purchase demo should give you ideas too.
