Forum Discussion
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
- adudani
Memorable Member
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)