Calculate Distance Between Two Addresses


#1

I categorized this post under “support” because I suspect it can be accomplished without any additional functionality from Airtable but, if not, it may be more appropriate as a “feature request.”

Is it possible to have a field that calculates the distance (in miles/kil) between two address fields? I am trying to create a base to log miles driven for business since the IRS requires a milage log to take advantage of the “standard mileage deduction.”


Drive Time Calculation
#2

I don’t know any formula function to to this. Also, I think it can’t be done with Blocks.


#3

It appears to be a simple Zapier task but requires a paid Zapier account. (I say ‘appears’ because I was able to build a three-stage Zap — trigger on new Airtable record; issue request to Google Maps Distance Matrix API and receive response; update Airtable record. Component testing worked fine, but to perform an end-to-end systems test, I need a paid Zapier account.)

Essentially, I defined an Airtable table with three fields: {Origin}, {Destination}, and {Distance}. ({Origin} and {Destination} are single-line text; {Distance} is number.)

I then configured a three-step Zapier webhooks zap:

Trigger

Airtable account, ‘Distance test’ base, [Test] table
Trigger on new record

Action

Zapier webhook Get action.
URL: https://maps.googleapis.com/maps/api/distancematrix/json
Query string parameters:
units | imperial
origins | {Origin}
destinations | {Destination}
key | [My Google API key]

Send as JSON: no
Unflatten: yes

Action #2

Airtable account, ‘Distance test’ base, [Test] table
Action: Update record
Record: Use a custom value
Airtable: New record: Record ID
Set {Distance} to Zapier ‘Get’: Rows elements distance value

This sets {Distance} to the distance between the origin and destination addresses in meters; you’ll need to convert to miles for the IRS.


Drive Time Calculation
#4

Hmmm, ok thanks for the detailed response! I also don’t have a paid Zappier account and this issue isn’t quite worth it at this time.


#5

That’s what I thought. I think it would require a custom function option.