Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
SURYA3696
Frequent Visitor

Distance Calculation from Latitude & Longitude Data

Hello All,

 

I am trying to generate distance in KM from the Latitude & Longitude data that I have. The dataset contains more than 3000 lines and the frequency of data output is at a time interval of every 5 seconds. I initially tried to produce distance by dividing the speed (km/hr) by 5 seconds in Hours. But the distance I calculated did not look realistic (incorrect). 

 

Can someone help with this please. PBI Query.PNG

2 ACCEPTED SOLUTIONS
edhans
Super User
Super User

You need to use the haversine formula. There is no built in function for this in DAX or M, but the underlying functions are there, like SIN() in DAX or Number.Sin in M.

Seems pretty straightforward, just a bit tedious to build.

edhans_0-1694049990183.png

 


https://www.omnicalculator.com/other/latitude-longitude-distance#the-haversine-formula-or-haversine-...



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

Hello edhans, 

 

Thank you for the solution. This is definitely worked. 

View solution in original post

2 REPLIES 2
edhans
Super User
Super User

You need to use the haversine formula. There is no built in function for this in DAX or M, but the underlying functions are there, like SIN() in DAX or Number.Sin in M.

Seems pretty straightforward, just a bit tedious to build.

edhans_0-1694049990183.png

 


https://www.omnicalculator.com/other/latitude-longitude-distance#the-haversine-formula-or-haversine-...



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Hello edhans, 

 

Thank you for the solution. This is definitely worked. 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors