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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
JoeMar
New Member

Use distance to filter?

I have two tables in Power BI desktop called 'Centers' and 'Stores'. The 'Centers' table contains only my shopping center locations and has the columns: [CenterID], [CenterLatitude], and [CenterLongitude]. The 'Stores' table contains store locations and has the columns: [StoreID], [StoreLatitude], [StoreLongitude], and [CenterID].  The 'Centers' table has a one-to-many relationship with the 'Stores' table.  Some of the stores in the 'Stores' table are located within my shopping center and will have a matching value in the [CenterID] column.  The stores that have a null value in the [CenterID] column are not within my shopping centers.  I want to be able to select a shopping center location and show all of the store locations that are within X miles or less of my shopping center location including my stores.  How can I do this?

1 REPLY 1
adudani
Super User
Super User

hi @JoeMar ,

 

you can calculate the perpendicular distance between two points, mentioned in the post below:

Solved: Distance Calculation in Power BI - Microsoft Fabric Community

 

You need Latitude and Longitude to calculate the distance between two locations with following formula:

 

=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon2-lon1))*6371

 

ps: 6371 is Earth radius in km.

 

You can achieve it via either Power Query or DAX method.

 

Or you can use Google Map API as @cs_skit suggested.

 

 

i think you could filter by this distance column to get stores in proximity ( after selecting a point)

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.