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
Anonymous
Not applicable

Converting a Excel formula ino DAX

Hello all,

I have a question; I use the following excel formula to calculate the difference in KM between 2 lon lat points:

=IFERROR(ACOS(COS(RADIANS(90-E2)) *COS(RADIANS(90-I2)) +SIN(RADIANS(90-E2)) *SIN(RADIANS(90-I2)) *COS(RADIANS(F2-J2))) *6371;0)

(this formula is not mine but one I found on the internet) In the above formula note that:
E2 = LatPoint1
F2 = LngPoint1
I2 = LatPoin2
J2 = LngPoint1

I was wondering if it is possible to convert this formula to a DAX query, since it would be convenient to be able to do this in Power BI.

Thanks in advance,
L.Meijdam

1 ACCEPTED SOLUTION
Omega
Impactful Individual
Impactful Individual

Try: 

 

Distance = IFERROR(ACOS(COS(RADIANS(90-[Lat1]))*COS(RADIANS(90-[lat2]))+SIN(RADIANS(90-[Lat1]))*SIN(RADIANS(90-[lat2]))*COS(RADIANS([Lon1]-[Lon2])))*6371,0)

View solution in original post

2 REPLIES 2
Omega
Impactful Individual
Impactful Individual

Try: 

 

Distance = IFERROR(ACOS(COS(RADIANS(90-[Lat1]))*COS(RADIANS(90-[lat2]))+SIN(RADIANS(90-[Lat1]))*SIN(RADIANS(90-[lat2]))*COS(RADIANS([Lon1]-[Lon2])))*6371,0)
Anonymous
Not applicable

Hello @Omega,

 

Okay this was alot more straightforward than I expected but it works indeed.

 

Thanks

 

Best regards,

L.Meijdam

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.