Forum Discussion
tayusso
5 years agoNew Member
Problem calculating distance between two points with Latitude and longitude
Hi, im having some issues creating a new column that calculates the distance between two points. I have the latitude and longitude of both points, created a new column to give me the kilometers betw...
- 5 years ago
This is a column, so you should not use SELECTEDVALUE
The formula you wrote would work great in a measure, but not in a column. The column should be:
KM = var x1 = RADIANS(DMS[LAT OR]) var x2 = RADIANS(DMS[LAT DEST]) var y1 = RADIANS(DMS[LON OR]) var y2 = RADIANS(DMS[LON DEST]) var R = 6371 var lcos = SIN(x1)*SIN(x2)+cos(x1)*cos(x2)*cos(y1-y2) var arco = ACOS(lcos) return arco*RAlthough using a measure would be much better for memory if you increase your table size.
SteveCampbell
5 years agoMemorable Member
This is a column, so you should not use SELECTEDVALUE
The formula you wrote would work great in a measure, but not in a column. The column should be:
KM =
var x1 = RADIANS(DMS[LAT OR])
var x2 = RADIANS(DMS[LAT DEST])
var y1 = RADIANS(DMS[LON OR])
var y2 = RADIANS(DMS[LON DEST])
var R = 6371
var lcos = SIN(x1)*SIN(x2)+cos(x1)*cos(x2)*cos(y1-y2)
var arco = ACOS(lcos)
return
arco*R
Although using a measure would be much better for memory if you increase your table size.
SUMESHKUMAR22
7 months agoHelper IV
SteveCampbell ,
If I would like to convert this into 'Miles' then how the measure & calc column could be modified? Could you please help me with that ?
Thanks in advance