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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
fawkys
Frequent Visitor

Filter for Dynamic Calculated Measure

Hi, Folks. First of all, sorry for my bad english.

 

I want to create a filter based on a calculated measure. My calculated measure (shown below) is the distance between two places and it changes for each place I select. I have the coordenates of each place and use it to find the distance.

 

Km = CALCULATE(
var Lat1 = MIN('mapa.Foco'[Latitude])
var Lng1 = MIN('mapa.Foco'[Longitude])

var Lat2 = MIN('Mapa'[Latitude])
var Lng2 = MIN('Mapa'[Longitude])
---- Algorithm here -----
var P = DIVIDE( PI(); 180 )
var A = 0,5 - COS((Lat2-Lat1) * p)/2 + COS(Lat1 * p) * COS(lat2 * P) * (1-COS((Lng2- Lng1) * p))/2
var final = 12742 * ASIN((SQRT(A))) 
return final)

 

After this, I build a map with all places.

 

But what I want to do, is a filter for, when I select some point, I wanna see only places that are in a given radius (Km < 10, for example), and when I don't select any point, I want the map to show all points again.

 

When I use the "visual level filter", it's always filtered for the radius I wanna see and only works when some point is selected. If it doesn't have any point selected, the map shows nothing (and I want the map to show them all).

 

Thanks.

6 REPLIES 6
Anonymous
Not applicable

Hey!!! am facing the same issue. Do you have a solution for it?

Anonymous
Not applicable

Hey!!! am facing the same issue. Do you have a solution for it?

fawkys
Frequent Visitor

I was thinking in a way to use a calculated column instead of a calculated measure.

With a column, it would be possible to use a Slicer for the distance.

 

The problem is that the measure needs to be static in the point I select and calculate the distance between all points and this specific point. And when I select no point, It can shows everything or nothing, doesn't matter.

 

Can someone help me to build this calculated column?

Hi @fawkys,

Got it. When you select one point in the map, I wanna see only places that are in a given radius. Until now, we can't achieve it, because when we select one point in map, it only shows the selected one place and related points. While tables are related by rows in Power BI, so it's impossible for it. When you use the distance in visual level filter, it will filter the whole visual, which doesn't change as you select one point or not.

Best Regards,
Angelia

v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @fawkys,

You create the measure and add the measure Km as visual level filter, and filter the visual using is less than or equal to 10, right? If it is, when you select points, it will calculate the km based on your selected points. If no pints is selected, the Km will returns one value based on all points, please create a card visual to display what the value is, and check it is less/more than 10.

I can't reproduce your scenario, could you please share your .pbix file for further analysis? You can share it by private message if your data is confidential. Thanks for understanding.

Best Regards,
Angelia

Hi, @v-huizhn-msft! Thank you for your answer.

 

I can't share my data with you, but my work looks like this. If you get any trouble to download, try this link.

In this work, the problem is the same as mine. If you don't select any city, the map shows nothing.

 

Thanks!

Helpful resources

Announcements
December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.