I am trying to use the following custom function DrivingKms
with ARRAYFORMULA
so that it recursively calculates the distance down the specified columns.
How can I update it so that it works with ARRAYFORMULA
?
function DrivingKms(origin, destination) {
return DrivingMeters(origin, destination)/1000;
}
function DrivingMeters(origin, destination) {
var directions = Maps.newDirectionFinder()
.setOrigin(origin)
.setDestination(destination)
.getDirections();
return directions.routes[0].legs[0].distance.value;
}
When I call the function in an ARRAYFORMULA
, from all the way down, it only converts the first two location points (F2 and M2).
={"DrivingKms";ARRAYFORMULA(IF(ISBLANK(A2:A),"",drivingkms(F2:F, M2:M)))}