# Help with Distance

**URL:** <https://community.glideapps.com/t/help-with-distance/47628>\
**Category:** Ask for Help\
**Created:** [August 24, 2022, 1:00pm UTC](https://community.glideapps.com/t/help-with-distance/47628 "2022-08-24T13:00:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joe\_Gabriele](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/joe_gabriele/32/57595_2.png) [@Joe\_Gabriele](https://community.glideapps.com/u/Joe_Gabriele)\
**Post date:** [August 24, 2022, 1:00pm UTC](https://community.glideapps.com/t/help-with-distance/47628/1 "2022-08-24T13:00:38Z")

</div>

Here is the scenario:

Restaurant database  
Food database

I have a restaurant app, where owners can have multiple locations and each location serves the same food items. Each restaurant location is a duplicate of each other with just a different address, so the same food items is related to all locations.

Example:  
Location 1: 100 Broadway  
Location 2: 100 Park Place

Food Item 1 is sold at both locations.

I can easily set the distance between the user and each of the restaurant locations. However, I am also interested in the user seeing how far they are from each food item at each location.

Currently, I have a lookup function to find the addresses of the Restaurants that the food is sold at. However, my distance column is only picking up the distance from Location 1, but I also want it to pick up the distance from location 2. Lastly, I need it to determine which location is the shortest and only show the food item at that closest location.

Example: If Food Item at Location 1 is 10 miles from the User and only 5 miles away at Location 2, to only show the 5 miles.

---

<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:** [August 24, 2022, 1:04pm UTC](https://community.glideapps.com/t/help-with-distance/47628/2 "2022-08-24T13:04:57Z")

</div>

Is each restaurant location in its own row, or do you have multiple location columns in the same restaurant row?

---

<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:** [August 24, 2022, 1:15pm UTC](https://community.glideapps.com/t/help-with-distance/47628/3 "2022-08-24T13:15:46Z")

</div>

If each restaurant location is in a separate row, you can do something like this.

- Make sure you have a multiple relation to the Restaurants table.
- Create a Lookup column to retrieve all of the distances to all locations from the relation
- Use a Sort Array column to sort the Lookup values in numeric order.
- Use a Single Value column to get the first item from the Sort Array.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/d/cd948f91abf8fb52aaf054b368355c69f183fcf3.png)

---

<div class="post-metadata">

**Author:** ![Joe\_Gabriele](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/joe_gabriele/32/57595_2.png) [@Joe\_Gabriele](https://community.glideapps.com/u/Joe_Gabriele)\
**Post date:** [August 24, 2022, 3:25pm UTC](https://community.glideapps.com/t/help-with-distance/47628/4 "2022-08-24T15:25:47Z")

</div>

Yes each restaurant has its own row.

I will try your below solution. Thank you!

Worked! Thanks, that was much easier than I thought!

---

<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:** [August 24, 2022, 4:08pm UTC](https://community.glideapps.com/t/help-with-distance/47628/6 "2022-08-24T16:08:05Z")

</div>

I see you deleted your other question, but I’ll respond anyway. You’ll need to add a math column with a multiply by 1 to make sure it truly gets converted to a number. Then your visibility should be able to see it as a number for numeric comparisons.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/5/e56d1046c20b6155505535135a49a056eeae2d74.png)

---

<div class="post-metadata">

**Author:** ![Joe\_Gabriele](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/joe_gabriele/32/57595_2.png) [@Joe\_Gabriele](https://community.glideapps.com/u/Joe_Gabriele)\
**Post date:** [August 24, 2022, 4:33pm UTC](https://community.glideapps.com/t/help-with-distance/47628/7 "2022-08-24T16:33:38Z")

</div>

Thanks! I thought I figured it out… but didnt work in the end lol. Your above works perfectly.

---

<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:** [August 25, 2022, 4:33pm UTC](https://community.glideapps.com/t/help-with-distance/47628/8 "2022-08-25T16:33:57Z")

</div>

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