web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Default fields based o...
Power Apps
Unanswered

Default fields based on current location

(1) ShareShare
ReportReport
Posted on by 43

Hi,

 

I have a list of physical assets in a SP list this includes columns for latitude and longitude as well as the address for this asset. I would like for my app to recognise my current location and use this to then pull the information from the SP list to populate a form based on that.

 

Basically use my current lat and long to match that in the SP list (I'm aware getting these to be exact matches won't really work so will have to be in the vicinity of).

 

Has anyone done anything similar and can suggest a way to make this work?

 

Thanks in advance 

Categories:
  • mdevaney Profile Picture
    29,993 Moderator on at

    @KathrynHughes 
    For example, lets say you have an asset in your table like this called 'Assets Table'.

     

    Asset (text) Latitude (number) Longitude (number)
    Flamethrower 100.000100 50.000500

     

     

    Now place a gallery on your app's screen with this code in the Items property with some code like this.

    Filter('Assets Table',
     Latitude + 0.000100 >= Location.Latitude
     And Latitude - 0.000100 <= Location.Latitude
     And Longitude + 0.000100 >= Location.Longitude
     And Latitude - 0.000100 <= Location.Latitude
    )

     

    You'll want to adjust the numbers according to the range you want to find assets within.

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • tgibso2 Profile Picture
    11 on at

    Hi Kathryn,

     

    I've developed something similar. I have a SharePoint list with the location name, latitude and longitude. I import this into a collection using:

    ClearCollect(Collection1, 'SharePoint List');

     

    From there I add another action to create a second collection with an additional column that calculates the distance between the user and the site:

    ClearCollect(Collection2,
    AddColumns(Collection2,"Distance",
    Acos(Cos(Radians(90-(Value(Latitude)))) *Cos(Radians(90-(Location.Latitude))) +Sin(Radians(90-(Value(Latitude)))) *Sin(Radians(90-(Location.Latitude))) *Cos(Radians((Value(Longitude))-(Location.Longitude)))) *6371))

    Using the equation from this website.

    "Latitude" and "Longitude" are the column headings for the site locations from Collection1 (i.e. the SharePoint List).

     

    Then I can create a drop down sorted by distance:

    Distinct(SortByColumns(Collection2,"Distance"),LocationName)

     

    Hope that helps!

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 394 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

Last 30 days Overall leaderboard