Hi @rowanb ,
Do you want to filer your Gallery Items based on the Text control value within this Gallery rather than a column from the Gallery data source?
If you want to filer your Gallery Items based on the Text control value within this Gallery rather than a column from the Gallery data source, I afraid that there is no way to achieve your needs in PowerApps.
When you want to filter your Gallery Items, the filter column must come from the data source the Gallery related to. You could not use Text control value within same Gallery as Filter column, it make no sense.
I assume that you add columns in your data source to store the Latitude value and Longitude value of the target location, is it right? As an alternative solution, you could consider calculate the distance for each record in your data source, then add a temporary column (called "Distance") to store the distance value using AddColumns function, then sort your data source records by the "Distance" column in Ascending order.
The sample formula looks like below (set the Items property of the Gallery to following) :
SortByColumns(
Search(
AddColumns(
Table1,
"Distance",
ACOS(Cos(Radians(90-DeviceLat))*Cos(Radians(90-ThisItem.Latitude))+Sin(Radians(90-DeviceLat))*Sin(Radians(90-ThisItem.Latitude))*Cos(Radians(DeviceLong-ThisItem.Longitude)))*6371
),
TextInput1.Text,
"Address","City","Mall Name","Location / Dealer Name (Primary)","DBM/AM"
),
"Distance",
Ascending
)
or
SortByColumns(
AddColumns(
Table1,
"Distance",
ACOS(Cos(Radians(90-DeviceLat))*Cos(Radians(90-ThisItem.Latitude))+Sin(Radians(90-DeviceLat))*Sin(Radians(90-ThisItem.Latitude))*Cos(Radians(DeviceLong-ThisItem.Longitude)))*6371
),
"Distance",
Ascending
)
Please check and see if my response within the following thread would help in your scenario:
https://powerusers.microsoft.com/t5/Building-Power-Apps/Sort-gallery-by-closest-location-after-search-is-it-possible/m-p/183247
Best regards,