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
BTMoylan
Frequent Visitor

Distance Filter Not Working

Hey All! 

 

I am trying to make a contact list that I can filter via business type, and distance to a certain location. The filtering through business type is working perfectly, just set up a slicer and choose the business type. However, I cannot seem to get the Distance Filter to work. 

 

I have based a lot of this tool on a project that was posted online at this link below. 

https://dataveld.com/2019/03/20/display-points-within-a-distance-radius-on-a-power-bi-map/

 

The person who made with was able to choose one city & state, and then filter out locations that were not within the range chosen. 

 

I have been trying to do the exact same thing, each business has been assignd a Longitude and Latittude, and based off the Job Location, I am trying to filter out anyone that is not within the range chosen. 


Map.jpg

 

Shown below is my Export Table, this shows all the businesses that have ben filtered down via there type and proximity to a job. The 'City' & 'State' Columns are the businesses location. The 'Distance (km)' column is working correctly, the numbers given are correct and when I change the Job Location, the numbers given in this column adjust correctly. So as far as I can tell this part is working correctly.

 

Points in Proximity.jpg

For some reason the 'Points in Proximity' column does not work properly. As you can see, every business appears to be "Out of Range". Even though their Distance from the Job Location is <= to the Max Distance. In this case the Maximum Distance is 120 KM. Ideally everything with a Distance less than or equal to the chosen Maximum Distance (120 KM) would show as "In Range", but for whatever reason that is not the case.

 

Points in Proximity = IF('Organization_Info'[Distance (km)] <= 'Maximum Distance (km)'[Maximum Distance (km) Value],"In Range","Out of Range")

PIP fx.jpg

 

The Max Distance is just a generated series of numbers so that I can choose a radius around the Job Location. 

 

Maximum Distance (km) = GENERATESERIES(0, 200, 1)

Max Distance.jpg

 

I have a Measure of this series so that I can create the IF statement in the 'Points in Proximity' measure. 

 

Maximum Distance (km) Value = SELECTEDVALUE('Maximum Distance (km)'[Maximum Distance (km)])

Max Distance fx.jpg

 

I cannot figure out why the 'Points in Proximity' measure is not working properly, either my IF statment is not correct or the 'Maximum Distance' measure is not correct. They both look correct to me, but clearly I am wrong, so any help would be appreciated.  

1 ACCEPTED SOLUTION
BTMoylan
Frequent Visitor

I didn't solve this problem directly but I was able to solve it indirectly. I was able to remove the 'Max Distance' Slicer and replace with a column called Area of Operation in a table also called 'Area of Operation'.

 

I made a new table, called Area of Operation, that had the name of each organization and then a column that contained the operating radius of that company in kilometers. So then I changed my Points in Proximity equation. You will see that monay of the business have a 5000 KM range. This just means they will travel/deliver anywhere within the state or country and they will always return "In Range". While other companies have a much smaller range of operation. 

 

Points in Proximity = IF('Organization_Info'[Distance (km)] <= SUM(Area_of_Operation[Area of Operation (km)]),"In Range","Out of Range")
Aera of Operation Table.png
 
I also had the state columns that could be used as additional filters within the report, as the radius of operation for some these business would be large enough to bleed into that state. I did this because some of these businesses do not operate in that state, even though their radius may extend into a bordering state.
 
As you will see below, I then made individual slicers for each state column from the 'Area of Operations' table. This allows me to further filter my results by only choosing businesses that operate within that state.
Aera of Operation Slicers.png
 
Not the prettiest of solutions but it did allow me to filter my results properly. 

View solution in original post

5 REPLIES 5
BTMoylan
Frequent Visitor

I didn't solve this problem directly but I was able to solve it indirectly. I was able to remove the 'Max Distance' Slicer and replace with a column called Area of Operation in a table also called 'Area of Operation'.

 

I made a new table, called Area of Operation, that had the name of each organization and then a column that contained the operating radius of that company in kilometers. So then I changed my Points in Proximity equation. You will see that monay of the business have a 5000 KM range. This just means they will travel/deliver anywhere within the state or country and they will always return "In Range". While other companies have a much smaller range of operation. 

 

Points in Proximity = IF('Organization_Info'[Distance (km)] <= SUM(Area_of_Operation[Area of Operation (km)]),"In Range","Out of Range")
Aera of Operation Table.png
 
I also had the state columns that could be used as additional filters within the report, as the radius of operation for some these business would be large enough to bleed into that state. I did this because some of these businesses do not operate in that state, even though their radius may extend into a bordering state.
 
As you will see below, I then made individual slicers for each state column from the 'Area of Operations' table. This allows me to further filter my results by only choosing businesses that operate within that state.
Aera of Operation Slicers.png
 
Not the prettiest of solutions but it did allow me to filter my results properly. 
HotChilli
Super User
Super User

Having looked over what you've posted I'm pretty sure you really want Points in Proximity to be a measure because it has to respond to the choices of the slicers.

So rework that as a measure and see how you get on

Points in Proximity is already a Measure. 

 

Points in Proximity = IF('Organization_Info'[Distance (km)] <= 'Maximum Distance (km)'[Maximum Distance (km) Value],"In Range","Out of Range")

HotChilli
Super User
Super User

First of all, measures should not be used in calculated columns.  I see quite a few examples of this on the forum and it's a bad idea.

The other problem though is that you might be assuming what the number is that you are getting from that measure.

Am i right in saying the calculated column Points in Proximity is created in the 'Organization_Info' table? What value is supposed to be returned from the 'Maximum Distance (km)' table to use it in a comparison?  I don't see any relationship so the SELECTEDVALUE will probably be returning the 1st or last value in the table and I don't think that's what you want.

 

HotChilli, I love your name thanks for helping me out lol. 

 

1. The reason I used a measure in the calculated column, was because I'm not sure how else I could accomplish that calculation, but if you know better then I would happily use your suggestion. 

2. You are correct in saying that the PiP is created in the 'Organizational_Info' table.

3. 'Maximum Distance (km)' is supposed to simply serve as a radius around a city. That number is then compared to the 'Distance' calculation for a given business. Any business within that radius will appear as "In Range", or just filter out any business not in the radius. 

4. Yeah I am confused on how SELECTEDVALUE is supposed to work. I pulled most of what I am doing from that link I provided at the top. The person who made that project provided a github download and I have been trying to recreate what they did. 

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.