Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin 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.
I'm trying to determine the closest point to any given point on an XY scatterplot. For simplicity, data is plotted on a 10x10 XY axis. How can I calculate the minimum distance from each point to any other point on the scatterplot? I'm trying to use something as follows, but to return the minimum sqrt:
Distance =
var x1 = SELECTEDVALUE(Locations[X])
var x2 = values(Locations[X])
var y1 = SELECTEDVALUE(Locations[Y])
var y2 = values(Locations[Y])
var result =
sqrt(power((x2-x1),2)+power((y2-y1),2))
return
result
Solved! Go to Solution.
Probably something like:
Distance =
VAR x1 = SELECTEDVALUE(Locations[X])
VAR y1 = SELECTEDVALUE(Locations[Y])
VAR __Table =
ADDCOLUMNS(
FILTER(ALL(Locations),[X] <> x1 && [Y] <> y1)
"distance",SQRT(POWER(([X] - x1),2) + POWER(([Y] - y1),2))
RETURN
MINX(__Table,[distance])
Probably something like:
Distance =
VAR x1 = SELECTEDVALUE(Locations[X])
VAR y1 = SELECTEDVALUE(Locations[Y])
VAR __Table =
ADDCOLUMNS(
FILTER(ALL(Locations),[X] <> x1 && [Y] <> y1)
"distance",SQRT(POWER(([X] - x1),2) + POWER(([Y] - y1),2))
RETURN
MINX(__Table,[distance])
Thank you, Greg. This definitely works!
The only tweak I'd need is that I can't exclude points that match the selected X or Y. Any way to just remove the given point and not all related x/y values?
Perfect. Thanks!
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 3 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 8 | |
| 7 | |
| 6 |