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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Distance calculation by selecting two points from map

The title is self explanatory, so I want to calculate the distance between 2 points that I select from the map.

The answer should show in a cardboard, and if more than 2 points are selected, the Cardboard should show (Blank).

What I have in hand:

1- Coordinates of all my points (Lat,Long).

2- The formula to calculate the distance between 2 points using coordinates.

The distance is the straight line between the two points, not a driving distance or anything special. 

Question 2 (less important): it is possible to draw a circle with a certain radius around each point I select?

 

NOTE: ARCGIS or NORMAL Powerbi MAP allowed!

 

 

1 ACCEPTED SOLUTION
AllisonKennedy
Community Champion
Community Champion

@Anonymous  I think it could be done if you did a couple checks -

 

Distance Measure = IF( COUNTROWS(LatLongTable) = 2, 

VAR _LatA = Min(Lat)

VAR _LongA = Min(Long) 

VAR _LatB = Max(Lat)

VAR _LongB = Max(Long)

RETURN

[DistCalc]

)

 

I don't know how your table is formatted, but you will need to be more precise with the Min/max lat and long to make sure they actually correspond to each data point, and that you don't use lat from one and long from the other. 

 

Drawing the circle of radius I have met someone who I think said they achieved this, but I don't recall how....


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

4 REPLIES 4
AllisonKennedy
Community Champion
Community Champion

@Anonymous  I think it could be done if you did a couple checks -

 

Distance Measure = IF( COUNTROWS(LatLongTable) = 2, 

VAR _LatA = Min(Lat)

VAR _LongA = Min(Long) 

VAR _LatB = Max(Lat)

VAR _LongB = Max(Long)

RETURN

[DistCalc]

)

 

I don't know how your table is formatted, but you will need to be more precise with the Min/max lat and long to make sure they actually correspond to each data point, and that you don't use lat from one and long from the other. 

 

Drawing the circle of radius I have met someone who I think said they achieved this, but I don't recall how....


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

Excellent! Thank you so much! The logic works, now i need to figure out how to make the calculation work. Thank you again!

amitchandak
Super User
Super User

@Anonymous , refer if these can help

https://community.powerbi.com/t5/Desktop/Distance-Calculation-in-Power-BI/td-p/206979

https://stackoverflow.com/questions/27928/calculate-distance-between-two-latitude-longitude-points-haversine-formula

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Indeed, I have seen those and that is why I said in my question that I know the formula. What I am asking for precisely is a way to do that by selecting those points on the map directly (if that is possible).

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

Users online (3,342)