Question: Is it possible to do this?

Hi! I have a list of store locations in my app. My users often visit these stores and write reports for them. Is it possible in AppSheet to use the userโ€™s current location to find the store that they currently are at (I have an Address column in the table), or is it possible to rank stores based on how close they are to the user (probably not, just want to make sure)?. Thank you!

Solved Solved
0 11 885
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

Yep, itโ€™s possible, so long as each store has its LatLong location (in column Location, e.g.). The closest store to the user can be found with:

ANY(
  ORDERBY(
    FILTER("Stores", TRUE),
    DISTANCE(HERE(), [Location])
  )
)

See also:



View solution in original post

11 REPLIES 11

Steve
Platinum 4
Platinum 4

Yep, itโ€™s possible, so long as each store has its LatLong location (in column Location, e.g.). The closest store to the user can be found with:

ANY(
  ORDERBY(
    FILTER("Stores", TRUE),
    DISTANCE(HERE(), [Location])
  )
)

See also:



How do I convert address to Lat Long using virtual column? Thanks!

Have a Wonderful Day! - Nick Barry RPC

You cannot, at least not within AppSheet. Youโ€™ll have to get the coordinates some other way.

Thanks! I found a google add-on that works great. โ€œGeocode by Awesome Tableโ€

Also, I have a follow up question. Where do I plug in your formula? Do I make a slice? Also,

ORDERBY(FILTER(โ€œMaster Store Listโ€,TRUE),DISTANCE(HERE(),[Latitude, Longitude]))

By removing the ANY part, it should include the full list, right, just ranked instead of 1 value? Thanky ou!

My end goal is to have a table view for my user that shows the stores closest to him, ranked.

Depends on how you want to use it.

If you want to capture the location without the user interaction (and possibly without their knowledge), use the expression with ANY() as the Initial value expression of the column to contain the location.

If you want to give the user the opportunity to choose their location, use the expression without ANY() as the Valid If expression of the column to store the userโ€™s location.

If you set both Initial value and Valid If as described above, the location will be auto-filled so the user doesnโ€™t need to do anything if itโ€™s correct, but will have a sorted dropdown to choose from if the user needs to correct the auto-chosen value.

Correct. You could optionally wrap the ORDERBY() expression with TOP() if you wanted to limit the number of choices to, say, the closest 5, or the closest 10.

See also:



Sorry for my many follow up questions, and thankyou for your help, but how would I acheive a table view ranked by how close a user is to them? My goal is to have a table with 5 locations, and the top one is the closest location, the second one is the second closest, and so on. Is this possible? Again, thankyou very much!

I figured it out. I made a virtual DISTANCE column using your distance formula, and then I sorted the table by those values ascending, so the ones with the least distance from current location would be at the top. Thank you very much, this is a cool feature I didnโ€™t know existed!

Hi Nick, Iโ€™m trying to do the same thing as you but not sure how to get the table view on my start page to sort by closest distance to the user. Could you explain how you did that? I have each Location LatLong setup and sorted the Table by Location (Ascending/Descending) but canโ€™t get the table view to update properly even though the map shows my current location HERE(). Thanks! @Steve

The table would need a virtual column with an App formula expression like:

DISTANCE([latlong-column], HERE())

replacing latlong-column with the name of the column containing the location associated with the row. Then sort the view by this virtual column.

Top Labels in this Space