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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
RFederer
Frequent Visitor

Distance function without latitude and longitude

Hi community,

 

I have many address of clients in a mapview visual. There is a way that let me define one function "distance", whitout using latitud and longitud (becouse I don't have this type of date) that show me all the client that are nearly the first one.

 

For example: i filtered one client,NAME1, in the map so i only see one point, but if NAME2, is near NAME1 I don't see it. Is there a may to fix that?

 

Thank you all

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @RFederer ,

You can try to use DAX and normal Power BI map visual objects for your needs. Finding distance along the edge of a sphere calls for the haversine formula. For example:

Distance (km) =
VAR __latSelected = SELECTEDVALUE('US Cities'[Latitude])
VAR __lonSelected = SELECTEDVALUE('US Cities'[Longitude])
VAR __radius = 6371
VAR __multiplier = PI()/180
VAR __latDiff = (MIN('Selector'[Latitude])-__latSelected) * __multiplier
VAR __lonDiff = (MIN('Selector'[Longitude])-__lonSelected) * __multiplier
VAR __formula1 =
    SIN(__latDiff/2) * SIN(__latDiff/2) +
    COS(MIN('Selector'[Latitude]) * __multiplier) * COS(__latSelected * __multiplier) *
    SIN(__lonDiff/2) * SIN(__lonDiff/2)
VAR __formula2 = 2 * ATAN(DIVIDE(SQRT(__formula1),SQRT(1-__formula1)))
VAR __distance = __radius * __formula2
RETURN __distance

I found an article about displaying all the points on a map within a specified radius that I hope will help you. And you can find the sample pbix and detailed realization steps here:
Display Points within a Distance Radius on a Power... - Microsoft Fabric Community

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @RFederer ,

You can try to use DAX and normal Power BI map visual objects for your needs. Finding distance along the edge of a sphere calls for the haversine formula. For example:

Distance (km) =
VAR __latSelected = SELECTEDVALUE('US Cities'[Latitude])
VAR __lonSelected = SELECTEDVALUE('US Cities'[Longitude])
VAR __radius = 6371
VAR __multiplier = PI()/180
VAR __latDiff = (MIN('Selector'[Latitude])-__latSelected) * __multiplier
VAR __lonDiff = (MIN('Selector'[Longitude])-__lonSelected) * __multiplier
VAR __formula1 =
    SIN(__latDiff/2) * SIN(__latDiff/2) +
    COS(MIN('Selector'[Latitude]) * __multiplier) * COS(__latSelected * __multiplier) *
    SIN(__lonDiff/2) * SIN(__lonDiff/2)
VAR __formula2 = 2 * ATAN(DIVIDE(SQRT(__formula1),SQRT(1-__formula1)))
VAR __distance = __radius * __formula2
RETURN __distance

I found an article about displaying all the points on a map within a specified radius that I hope will help you. And you can find the sample pbix and detailed realization steps here:
Display Points within a Distance Radius on a Power... - Microsoft Fabric Community

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.