Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (17.6k points)

I have a data file with millions of rows with lat and long columns as 2 of the field in the columns.

Would like to ask if there is anyways to calculate the total distance for (e.g. Model X "Index 0 --> Index1, Index 1--> Index 3" ) using the lat long field

Index,Model,lat,long

0,X,1.3539,103.84

1,X,1.3545,103.84

2,Y,1.3839,103.7002

3,X,1.3548,103.84

4,Y,1.3831,103.71

5,Z,1.3139,103.88

Please advice!

1 Answer

0 votes
by (47.2k points)

This formula will calculate distance. In order to make it work, you'll need to either use the lookup() function to look at the next row or somehow pivot your data so that you have two sets of coordinates on the same row.

3959 * ACOS 

SIN(RADIANS([Lat])) * SIN(RADIANS([Lat2])) + 

COS(RADIANS([Lat])) * COS(RADIANS([Lat2])) * COS(RADIANS([Long2]) - RADIANS([Long])) 

)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...