DISTANCE functions

This article explains how to use our unique DISTANCE functions in combination with the Place element

We have created powerful bespoke functions that allow you to calculate using the outputs of the Place-question. The following functions are now available:

  • DISTANCE()
  • DRIVINGDISTANCE()
  • DRIVINGDURATION()

These functions were already available in the background of our Places-question. The DISTANCE functions will give you more flexibility.

DISTANCE()

The distance function returns the distance between two coordinates (places) in a selected unit (as the crow flies). A coordinate contains the latitude & longitude, giving the DISTANCE function a total of 5 arguments:

FS
DISTANCE(lat1, lng1, lat2, lng2, unit)
  • 'lat1': the latitude of the first place
  • 'lng1': the longitude of the first place
  • 'lat2': the latitude of the second place
  • 'lng2': the longitude of the first place
  • 'unit': The unit in which you want to express the output. Available units: "m", "ft", "km", "mi", "in" (default "m"). Make sure you include quotation marks around the unit since the function will otherwise throw an error.

You can either use raw longitude and latitude data or use the lat and long from a Place-question:

FS
DISTANCE(51.91670188501261, 4.488032213665693, 51.89402927794878, 4.52355382345693, "mi") DISTANCE(51.91670188501261, 4.488032213665693, QA_lat, QA_lng, "mi") DISTANCE(51.91670188501261, 4.488032213665693, QA_latitude, QA_longitude, "mi")

DRIVINGDISTANCE()

The driving distance function has a similar syntax to the distance function. The difference between both functions is the output since the driving distance takes the road distance into account.

FS
DRIVINGDISTANCE(lat1, lng1, lat2, lng2, unit)

DRIVINGDURATION()

The driving duration returns the duration in seconds, minutes, or hours.

FS
DRIVINGDURATION(lat1, lng1, lat2, lng2, unit)
Where 'unit' is "s", "min", "h", (default "s").

Learn more about how Google determines the distance, driving distance, and driving duration here.

Latitude/Longitude Calculator

Use the below calculator to retrieve the latitude and longitude of your location of choice.

Related articles

Learn more about distance in one of the following articles