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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.