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.
Hi,
I create calculated column to compute distance between 2 locations.
End state would be:
1. Compute results excluding the location itself
2. Do not put any value on results if either of the value of latitude & longitude is blank.
Here is my code credits to @AIB:
Distance (KM) =
VAR Lat1 = facilities_tbl[Latitude]
VAR Lng1 = facilities_tbl[Longitude]
VAR name_ = facilities_tbl[Name of plant]
VAR P =
DIVIDE ( PI (), 180 )
RETURN
MINX (
FILTER ( facilities_tbl, facilities_tbl[Name of plant] <> name_ ),
VAR Lat2 = facilities_tbl[Latitude]
VAR Lng2 = facilities_tbl[Longitude]
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
)
Here's the result:
Should not include the 0s in the results if either of the latitude or longitude is blank.
Thanks
Solved! Go to Solution.
Change the RETURN expression to:
...
RETURN
IF (
OR (
ISBLANK ( facilities_tbl[Latitude] ),
ISBLANK ( facilities_tbl[Longitude] )
),
BLANK (),
final
)
Proud to be a Super User!
Paul on Linkedin.
Change the RETURN expression to:
...
RETURN
IF (
OR (
ISBLANK ( facilities_tbl[Latitude] ),
ISBLANK ( facilities_tbl[Longitude] )
),
BLANK (),
final
)
Proud to be a Super User!
Paul on Linkedin.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
92 | |
74 | |
63 | |
62 |
User | Count |
---|---|
143 | |
104 | |
104 | |
80 | |
66 |