Problem Statement:
You have addresses and you need to identify GPS co-ordinates and calculate the driving time and duration between two points. Using the Alteryx distance tool, you get the straight line distance instead of the drive route. You can use Google Maps API to calculate the distance but it has a limitation of certain number of requests per day on its free account that’s when Bing Map API comes in.
Pre-requisites:
- Data file with addresses (From Address and To Address)
- Alteryx Desktop
Bing API Key which can be obtained from https://www.bingmapsportal.com/
Information is available on https://docs.microsoft.com/en-us/bingmaps/getting-started/bing-maps-dev-center-help/getting-a-bing-maps-key
Solution:
If you have addresses and you want to get the distance and driving time between these address.
DepartFrom | ArriveAt |
You Yangs Regional Park, Branch Rd, Little River VIC 3211, Australia | Kinglake National Park, Kinglake West VIC 3757, Australia |
Step 1: Prepare the data
Prepare your data in the following format for ease


Step 2: Identify the Lat/Long of the addresses
Create a bing API request in the following format.
"http://dev.virtualearth.net/REST/v1/Locations?countryRegion="+[countryRegion]+"&adminDistrict="+[State]+"&locality="+[Locality]+"&postalCode="+[Postcode]+"&addressLine="+[addressLine]+"&maxResults=1&o=xml&key="+[bingmaps.key]
Where;
[countryRegion]
[State]
[Locality]
[Postcode]
[addressLine]
[bingmaps.key]
are the variables
Download the alteryx workflow to understand how I created an API request. Repeat the same steps for Destination.
I used formula tool to create these fields and download tool to send the API request.
Step 3: Calculate the driving time and driving duration between the two GPS locations
Once you have the Origin/Destination Lats/Longs, send the API request to get the distance and duration using the following URL request.
"https://dev.virtualearth.net/REST/v1/Routes/DistanceMatrix?origins="+[Origin]+"&destinations="+[Destination]+"&travelMode="+[travelMode]+"&o=xml&key="+[bingmaps.key]
Where;
[Origin]
[Destination]
[travelMode]
[bingmaps.key]
are variables.
Next use the XML parse tool to read Distance and Duration