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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Distance DAX

Hi Everyone,

 

I am trying to make graph on power BI by using Longtitude and Latitude information. I want to know how can I use DAX funtion in power BI to get the distance in miles from one point to anther Point.

I am attached the map graph which I just created on Power BI.

 

Amjad_1-1603387438569.png

Thanks

 

 

1 ACCEPTED SOLUTION

Are you looking for the distance of Every (all 50) points FROM the same Lat 43.72 and long -79.7 every time?

 

What was the first example Lat/Lon you used in testing to get 9.2 vs. 10.1?  (Assuming I have 43.72 x -79.7 as the starting point)

 

FOrrest




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




View solution in original post

13 REPLIES 13
fhill
Resident Rockstar
Resident Rockstar

I had to do this recently between zip codes in Excel.  You have to convert Lat & Lon cordinates into Radiant values first, then you can use the formula in the 2nd screen shot.  DAX has a RADIANS, SIN & COS calcuation just like Excel.

 

The hard part may be how to display this information?  You'll need 2 sets of Lat & Lon to perform the calcuation, and I don't know how you plan to 'match up' two points to do so?

 

fhill_2-1603391250534.png

 

 

fhill_1-1603391099133.png

 

fhill_0-1603391073409.png

 




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Anonymous
Not applicable

Return

I have one set of Latitude and Longtitude only. Can you resend the 3rd screen short little bigger?

Thanks

 

=IF(SIN(D2) * SIN(D3) + COS(D2) * COS(D3) * COS(F2 - F3) > 1,
3963.1 * ACOS(1), 3963.1 *
ACOS(SIN(D2) * SIN(D3) + COS(D2) * COS(D3) * COS(F2-F3)))

 

image.png




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Anonymous
Not applicable

Hi Fhill,

I have the same kind of data which you have. My question is when I check the distance on google map, it is showing me that 2.2 miles but my calculation showing me 1.99 miles. These diffrence are showing me all data. I am not sure why Radiants formula result have 1.99 miles and google have 2.20 miles.

Here is the screen shot I have.

 

Amjad_0-1603831159003.pngAmjad_1-1603831169841.pngAmjad_2-1603831178955.png

Thanks

 

 

 

Anonymous
Not applicable

I think, I get you wrong. So I have fifty rows of Latitude and 50 row of Longtitude.

When I use the formula you shared. I got 9.2152. My Lat is 43.72 and long is -79.7.

When I pug this lat and long into google map it is showing me 10.1 miles. Do you belive is there any problem?

Thanks

Amjad

Hi @Anonymous ,

 

can you provide a representative dataset?



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Are you looking for the distance of Every (all 50) points FROM the same Lat 43.72 and long -79.7 every time?

 

What was the first example Lat/Lon you used in testing to get 9.2 vs. 10.1?  (Assuming I have 43.72 x -79.7 as the starting point)

 

FOrrest




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Anonymous
Not applicable

Hi Fhill,

Sorry for late reply, I was away. So here is the detail.

I want to know all 50 lat and longtitude distance in miles from one location to see which one is best or near. 

for example, 43.42-80.70 to 43.78-79.55 and so on.

 

Thanks

 

 

Anonymous
Not applicable

Hi,

You used this formula to calculate miles ? If yes than you have one set of latitude and longtitude so how you calculate miles?

Thanks

Hi @Anonymous ,

 

please see the blog post below, shout out to radacad,com

https://radacad.com/dynamic-distances-in-power-bi

 

Hope this Helps,
Richard
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!



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Anonymous
Not applicable

I checked that already but not what I am looking for.

Thanks

AlB
Super User
Super User

Hi @Anonymous 

What  is the formula to get the distance based on Lat and long? Once you have it, the calculation should not be difficult.

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

Anonymous
Not applicable

Hi,

I do not have formula for that, I have data which have lon and lat.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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