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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
stathar0s
New Member

How to calculate the distance between a branch and all the other

Hi all!

I need your help!

 

I have the table 'Lat_Long' with three columns: Branch_ID, Lat, Long and I want, when I select a branch, to calculate the distance between this branch and all the other.

I 've made this measure:

Measure =

VAR Lat1 = SELECTEDVALUE('Lat_Long'[Lat])

VAR Lng1 = SELECTEDVALUE('Lat_Long'[Long])

VAR Lat2 = 'Lat_Long'[Lat]

VAR Lng2 = 'Lat_Long'[Long]

 

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

 

But, I see this error:

"A single value for column 'Lat' in table 'Lat_Long' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."

 

Your help please!

Thank you!

1 REPLY 1
Wilson_
Super User
Super User

Hello stathar0s,

 

Reading your error message and seeing where in your measure's syntax Power BI has highlighted would probably help. 🙂

 

Happy to help if you have more specific follow-up questions after that.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.