in a particular form I want a drop down menu of Airfields, pulled from an ‘Airfields’ table that includes index, name and LatLong columns. This bit is easy, however I want to sort the options in the dropdown menu in order of distance from current position [most likely selection will be first, as that’s where the user will likely be physically located at the time], with the initial value pre-populated with the closest.
So far I have created a [Distance] VC in the Locations table with the following formula:
distance( here(), [_THISROW].AirfieldLatLong] )
I was expecting this to give me the distance from current position for all Locations (Airfields), but when I ‘view data’ I get the below, with distances looking like they’re using my current position as 0.00,0.00
However, when I then view the table data in a UX I get them all listed in the correct order, showing the correct distance
I then tried to use the below formula to lookup the airfield name to set the initial value to the nearest, but it just returns the first in the list [which it thinks is nearly 6000km away, but actually more like 200, and not the closest]
min( Airfields[Distance] ), ‘Airfields’, ‘Distance’, ‘AirfieldName’
So, my questions:
- how come the UX can correctly show distances when the table view cannot?
- what’s the best way to achieve what I need, in terms of sorting the dropdown list in order of [Distance], using a ref data type, and pre-populating the initial value
Many thanks in advance for any advice