Forum Discussion

Balkrishnan's avatar
Balkrishnan
Helper II
6 years ago

Distance between two Cities

I am getting Errow when calculating distance between two cities.

 I used this formula

PI_D180 = PI()/180
Distance = ACOS(SIN(Distance[Latitude_1]*[PI_D180])*SIN(Distance[Latitude_2]*[PI_D180])+COS(Distance[Latitude_1]*[PI_D180])*COS(Distance[Latitude_2]*[PI_D180])*COS((Distance[Longitude_2]*[PI_D180])-(Distance[Longitude_1]*[PI_D180])))*3959
 
Getting  error as
An argument of function 'ACOS' has the wrong data type or the result is too large or too small.

5 Replies

  • smpa01's avatar
    smpa01
    Community Champion

    In M through creating custom column with sample LAT format as 45.5105 (decimal degrees)

     

    Lat1_Rad=([Latitude1]/180)*Number.PI
    Lon1_Rad=([Longitude1]/180)*Number.PI
    Lat2_Rad=([Latitude2]/180)*Number.PI
    Lon2_Rad=([Longitude2]/180)*Number.PI
    Distance_KM=Number.Acos(Number.Sin([Lat1_Rad]) * Number.Sin([Lat2_Rad]) + Number.Cos([Lat1_Rad]) * Number.Cos([Lat2_Rad]) * Number.Cos([Lon2_Rad]-[Lon1_Rad])) * 6371

     

    • Balkrishnan's avatar
      Balkrishnan
      Helper II

      Thanks for your attention on this, but i need in Miles and need to  know how to use your formula in my calculation.

      • Anonymous's avatar
        Anonymous
        Not applicable

        You can get the results in miles and then do a convertion multiplying the result by 1.6