<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=612681139262614&amp;ev=PageView&amp;noscript=1">
Skip to content

Need help? Talk to an expert: phone(904) 638-5743

Power Apps: Calculate Mileage Using Bing Maps [Power Platform Series - Ep. 11]

Power Apps: Calculate Mileage Using Bing Maps [Power Platform Series - Ep. 11]

In this video, Matt Peterson, a trainer at Pragmatic Works, demonstrates how to calculate mileage within a Power Apps canvas application using the Bing Maps connector. This practical use case originated from a real-world hackathon scenario, where IT technicians needed to log mileage between locations for reimbursement purposes.


Introduction to the Use Case

Matt Peterson introduces a business scenario where IT technicians travel between schools and need to track their mileage efficiently. Instead of manually calculating distances, he shows how Power Apps can automate this process using the Bing Maps connector.

This approach allows users to:

  • Enter starting and ending destinations
  • Automatically calculate travel distance
  • Store or use the mileage data within applications

Setting Up the Bing Maps Connector

The first step in this process is integrating the Bing Maps connector into Power Apps. Matt explains that this is a free connector, but it requires setting up an API key.

To configure the connector:

  1. Navigate to the Data section in Power Apps
  2. Select “Add Data” and search for Bing Maps
  3. Authenticate using an API key
  4. Add the connector to your application

Once connected, developers can access various mapping functionalities, including route calculations.

Building the User Interface

To demonstrate the functionality, Matt creates a simple interface using:

  • Two text input fields for addresses
  • A label to display calculated mileage

He renames the input fields for clarity:

  • inpStart – Starting destination
  • inpEnd – Ending destination

He also removes default values and adds hint text to guide users when entering addresses.

Using the Bing Maps Connector to Calculate Mileage

The core functionality lies in using the Bing Maps GetRoute function. Matt demonstrates how to construct the formula to calculate driving distance between two locations.

Key steps include:

  1. Selecting the Bing Maps connector
  2. Using the GetRoute function
  3. Specifying travel mode (driving)
  4. Passing start and end addresses
  5. Defining distance units (miles)

The function returns a record, so Matt highlights an important tip: use a period (.) after the function to explore available properties. In this case, the travelDistance property is used to extract the mileage value.

This calculated value is then displayed in the label for users to see in real time.

Testing the Application

Matt tests the application by entering sample addresses, such as the White House and a business location in Florida. The app successfully calculates and displays the mileage between the two points.

He notes that while Bing Maps provides accurate estimates, results may vary slightly depending on routing logic.

Improving User Experience with Conditional Logic

To enhance usability, Matt adds conditional logic to handle missing inputs. This ensures that users receive feedback when required fields are not completed.

He uses an If statement combined with IsBlank to check whether either input field is empty.

If either field is blank, the app displays a message:

  • “Location is missing for mileage”

Otherwise, it proceeds with the mileage calculation.

Key Takeaways

This demonstration highlights how Power Apps can integrate external services like Bing Maps to automate real-world business processes. Key benefits include:

  • Automated mileage tracking for reimbursements
  • Improved accuracy and efficiency
  • Enhanced user experience with validation logic
  • Scalability by connecting to real data sources

Matt Peterson emphasizes that this is just one example of what the Bing Maps connector can achieve. Developers can expand on this by integrating dropdowns, forms, or databases to create more robust solutions.

By leveraging Power Platform capabilities, organizations can streamline workflows and reduce manual effort in everyday operations.

 Don't forget to check out the Pragmatic Works' on-demand learning platform for more insightful content and training sessions on Power Apps and other Microsoft applications. Be sure to subscribe to the Pragmatic Works YouTube channel to stay up-to-date on the latest tips and tricks.  

Sign-up now and get instant access

Leave a comment

Free Community Plan

On-demand learning

Most Recent

private training

Hackathons, enterprise training, virtual monitoring