-
-
Save PBI-DataVizzle/b485496090a2d3b5776db118fc4b907d to your computer and use it in GitHub Desktop.
GetDistanceMiles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** GetDistanceMiles */ | |
/* | |
FUNCTION NAME: GetDistanceMiles | |
DESCRIPTION: Returns the distance in miles between points X and Y based on their | |
decimal latitude and longitude coordinates | |
ARGS: | |
LatX: Point X's decimal latitude | |
LngX: Point X's decimal longitude | |
LatY: Point Y's decimal latitude | |
LngY: Point Y's decimal longitude | |
EXAMPLE: | |
=GetDistanceMiles(39.4567,-109.123,33.789,-120.3456) | |
*/ | |
GetDistanceMiles = LAMBDA( | |
LatX, | |
LngX, | |
LatY, | |
LngY, | |
ACOS( | |
COS(RADIANS(LatX)) * COS(RADIANS(LatY)) * COS(RADIANS(LngY - LngX)) + | |
SIN(RADIANS(LatX)) * SIN(RADIANS(LatY)) | |
) * 3959 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment