# Find Value from Previous Row

**URL:** https://community.glideapps.com/t/find-value-from-previous-row/56330
**Category:** Ask for Help
**Created:** [January 4, 2023, 3:12pm UTC](https://community.glideapps.com/t/find-value-from-previous-row/56330 "2023-01-04T15:12:24Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Abhishek\_Sinha](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/abhishek_sinha/32/52361_2.png) [@Abhishek\_Sinha](https://community.glideapps.com/u/Abhishek_Sinha)
#### Post date: [January 4, 2023, 3:12pm UTC](https://community.glideapps.com/t/find-value-from-previous-row/56330/1 "2023-01-04T15:12:24Z")

</div>

Hi,  
I am new here but have used appsheet before.  
I have a table that stores Full Trip data and a related table that stores journeys in this trip.  
Example  
Full Trip - Place A - D  
Journeys in the trip -  
Place A - B  
Place C-D  
I am able to create a form to enter the related data.  
I want to find the distance between Place B to Place C.  
Since these are in different rows - I an unable to do this.  
Can anyone help ?

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [January 4, 2023, 4:14pm UTC](https://community.glideapps.com/t/find-value-from-previous-row/56330/2 "2023-01-04T16:14:43Z")

</div>

This is possible, but I have a question.

Can it be assumed that there could be several journeys in a trip?

For example, A-\>B, C-\>D, E-\>F

If that was the case, does that mean that you’d want to calculate the distance from both B-\>C and D-\>E?

And if so, how would you determine the order of the journeys? Would you rely on the order that they are entered, or would there be some other way?

---

<div class="post-metadata">

### Author: ![Abhishek\_Sinha](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/abhishek_sinha/32/52361_2.png) [@Abhishek\_Sinha](https://community.glideapps.com/u/Abhishek_Sinha)
#### Post date: [January 4, 2023, 5:09pm UTC](https://community.glideapps.com/t/find-value-from-previous-row/56330/3 "2023-01-04T17:09:50Z")

</div>

Thanks @Darren_Murphy  
Yes there would be several journeys in a trip.  
Yes i need to calculate both B-C & D-E in your example and if there are more then others too.  
Yes they are always entered in order.  
Thanks a ton.

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [January 5, 2023, 1:32am UTC](https://community.glideapps.com/t/find-value-from-previous-row/56330/4 "2023-01-05T01:32:51Z")

</div>

So I assume you store each place’s address/coordinates?

What you can do is this:

- Create an index for each row, as described below

> [@fishbaguette\_breadbasket Transpose Columns to an Inline List: The Miracle Method](https://community.glideapps.com/t/transpose-columns-to-an-inline-list-the-miracle-method/32766):
>
> I’m often asked how to take columns of data (say form responses) and display them in an inline list. Here’s one way to do it—the MIRACLE METHOD. [[Glide: Transpose Data Columns into an Inline List with the MIRACLE METHOD] ](https://www.youtube.com/watch?v=t-sh_Q3WbQc)

Please note that the index should be related to each “trip” only, since you want to index each row based only on their respective list. You should have a “Trip ID” that is unique to each trip.

- Create a Math column, name it “Previous Index”, take the index from the 1st step, minus 1.
- Create a Template column, name it “Previous Index Temp”, the template should join the “Previous index” and the “Trip ID”. E.g: 1 - abcdef.
- Create another Template column, name it “Current Index Temp”, joining the “Current Index” (step 1) and the “Trip ID”.
- Create a relation from the “Previous Index Temp” column to the “Current Index Temp”.
- Return the “Destination address/coordinates” from the relation. It should give you the address/coordinates of place B, D, F etc in Darren’s example.

---

<div class="post-metadata">

### Author: ![Abhishek\_Sinha](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/abhishek_sinha/32/52361_2.png) [@Abhishek\_Sinha](https://community.glideapps.com/u/Abhishek_Sinha)
#### Post date: [January 5, 2023, 10:21am UTC](https://community.glideapps.com/t/find-value-from-previous-row/56330/5 "2023-01-05T10:21:22Z")

</div>

Thanks a ton got it !

---

<div class="post-metadata">

### Author: ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)
#### Post date: [January 6, 2023, 10:22am UTC](https://community.glideapps.com/t/find-value-from-previous-row/56330/6 "2023-01-06T10:22:07Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
