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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Calcualte the distance...
Power Apps
Unanswered

Calcualte the distance between 2 locations (latitude & Latitude) using BingMaps.GetRouteV2

(0) ShareShare
ReportReport
Posted on by 1,809 Super User 2024 Season 1

I have an Asset with latitude & Latitude and i am getting it using this formula:-

 

Set(relatedAsset,LookUp(Assets,ID=LookUp('Asset Faces',ID= LookUp('ticket Details',ID=If(IsBlank(varticketID),varNavigationID,varticketID)).'Asset Face ID').'Asset ID'));

 

then i am getting the latitude & Latitude of the current technicians from SharePoint list as follow:-

 

ClearCollect(colRelatedticketTechnicianLocation,Filter('Technicians Locations','ticket ID'=If(IsBlank(varticketID),varNavigationID,varticketID)));

add a column to the collection:-

AddColumns(colRelatedticketTechnicianLocation,"Distance",0);

then i am trying to Forall the items inside the collection and calculate the distance between the Asset and the Technician:-

ForAll(colRelatedticketTechnicianLocation As ticketLocation,

Patch(colRelatedticketTechnicianLocation,LookUp(colRelatedticketTechnicianLocation,ID=ticketLocation.ID),{Distance: BingMaps.GetRouteV2()});
Blank()
)

 

but currently i am facing these 2 issues:-

 

1) i am not sure how to pass the source and distention latitude & Latitude inside the BingMaps.GetRouteV2 method?

 

2) inside the final statement , i am getting that it can not find a column named Distance, although i added it using the Addcolumns, any advice?

 

Thanks

 

Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    on at

    Hi @johnjohnPter ,

     

    2) inside the final statement , i am getting that it can not find a column named Distance, although i added it using the Addcolumns, any advice?

     

    The AddColumns function can not really add a new column for a table. Using the AddColumns function does not modify the data source, but returns a temporary table

     

    1) i am not sure how to pass the source and distention latitude & Latitude inside the BingMaps.GetRouteV2 method?

     

    Please try:

    ForAll(colRelatedticketTechnicianLocation As ticketLocation,
     Patch(
     colRelatedticketTechnicianLocation,
     LookUp(colRelatedticketTechnicianLocation,ID=ticketLocation[@ID]),
     {Distance: BingMaps.GetRouteV2(ticketLocation[@Point1Lat]&","&ticketLocation[@Point1Long],ticketLocation[@Point2Lat]&","&ticketLocation[@Point2Long]).travelDistance}
     )
    )

     

     

    Best Regards,

    Bof

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard