Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
Hi,
I have a matrix visual that displays the 10 closest customers (measured in Kilometers) to another customer, based on an independent slicer selection.
Customer Name | Sales Amount | Distance to Selected Customer |
Cust1 | 18 | 0.3 |
Cust2 | 71 | 0.4 |
Cust3 | 197 | 0.57 |
Cust4 | 29 | 0.87 |
Cust5 | 51 | 1.03 |
Cust6 | 5 | 1.03 |
Cust7 | 92 | 1.3 |
Cust8 | 154 | 1.56 |
Cust9 | 10 | 1.62 |
Cust10 | 13 | 2.41 |
The distance in Kilometers is calculated with the following DAX:
Distinace in Kilometers:= VAR Lat1 = MIN ( 'Customer X'[Lat] ) VAR Lon1 = MIN ( 'Customer X'[Lon] ) VAR Lat2 = MIN ( 'Customer Y'[Lat] ) VAR Lon2 = MIN ( 'Customer Y'[Lon] ) VAR P = DIVIDE ( PI (), 180 ) VAR A = 0.5 - COS ( ( Lat2 - Lat1 ) * p ) / 2 + COS ( Lat1 * p ) * COS ( lat2 * P ) * ( 1 - COS ( ( Lon2 - Lon1 ) * p ) ) / 2 VAR Final = 12742 * ASIN ( ( SQRT ( A ) ) ) RETURN Final
Ultimately, I want a dynamic measure that would display the maximum distance from CustX to CustY (in the above example, that would mean 2.41 Km) in a card visual and I am stumped.
Solved! Go to Solution.
You may refer to the following post.
You may refer to the following post.