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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
HenryJS
Post Prodigy
Post Prodigy

Calculating Distance Between Latitude / Longitude

Hi all,

 

I have a matrix with candidates in rows and sites in columns.

 

I have placed the below measure into the values however it is showing the same distances between the candidates and sites for a lot and not calculating the correct distance.

 

The candidates/sites are joined to tables of candidate/site longitude/latitude.

 

How can I fix so it calculates the distance between the candidates/sites in the x/y axis?

 

I can share example data if required.

 

 

Distance From Compound = 

var Lat1 = MIN('Candidate Postcodes'[Column6])

var Lng1 = MIN('Candidate Postcodes'[Column7])




var Lat2 = MIN('Company Postcodes'[Column6])

var Lng2 = MIN('Company Postcodes'[Column7])

---- 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

 

 

Capture.PNG

 

 

 

Capture1.PNG

1 ACCEPTED SOLUTION

Sure, would really need to see some sample data. I created a measure for doing exactly this @HenryJS so perhaps comparing your PBIX with the one included here: https://community.powerbi.com/t5/Quick-Measures-Gallery/Going-the-Distance/m-p/963267#M423


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Greg_Deckler , Please provide your input on this.

Sure, would really need to see some sample data. I created a measure for doing exactly this @HenryJS so perhaps comparing your PBIX with the one included here: https://community.powerbi.com/t5/Quick-Measures-Gallery/Going-the-Distance/m-p/963267#M423


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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