This was asked previously and then archived. This is also a crucial function I need in Quicksight. We are being forced to transition from PowerBI to Quicksight. We have a dashboard that calculates the distance between lat and long for two locations based on a table of all locations and a location selected (filter) by the end user. The “best” way to do this is through the haversine formula. This does not appear to be possible at all in Quicksight currently as SIN and COS are not available calculation options. This is the DAX code used in PowerBI to get the distance in miles. If there is another option to utilize in Quicksight, I’m open to it, but I do not believe there is.

Parameter Distance (mi) =

VAR __latSelected = SELECTEDVALUE(‘FC_Data’[latitude])

VAR __lonSelected = SELECTEDVALUE(‘FC_Data’[longitude])

VAR __radius = 3956

VAR __multiplier = PI()/180

VAR __latDiff = ([Parameter Selector Latitude Value]-__latSelected) * __multiplier

VAR __lonDiff = ([Parameter Selector Longitude Value]-__lonSelected) * __multiplier

VAR __formula1 =

SIN(__latDiff/2) * SIN(__latDiff/2) +

COS([Parameter Selector Latitude Value] * __multiplier) * COS(__latSelected * __multiplier) *

SIN(__lonDiff/2) * SIN(__lonDiff/2)

VAR __formula2 = 2 * ATAN(DIVIDE(SQRT(__formula1),SQRT(1-__formula1)))

VAR __distance = __radius * __formula2

RETURN __distance