Forum Discussion
Getting what Name or Id is a point inside multiple Polygons
- 1 year ago
Hi DanSanDST , Thank you for reaching out to the Microsoft Community Forum.
We reproduced your setup and built a DAX calculated column that filters polygons by zone, groups edges by polygon, applies the ray-casting algorithm per group and returns the first polygon that contains the point. If none match, it returns Outside. This gives you exactly what you need, dynamically, without hardcoding.
Please check the attached .pbix file for reference.
That said, this approach won't scale well. DAX has no spatial engine and evaluating every polygon’s edges per point is expensive. For larger datasets, I recommend moving this logic to Power Query or a Fabric notebook, where spatial operations are more efficient and maintainable.
please check your zone sample data. All of the "zones" are lines, not rectangles. A point cannot be "in" a zone in that case.
The algorithm works with an Edges table, meaning in a line you need x0/y0 and x1/y1 to make a segment.
The real polygons are complex and the algorithm works fine
- v-hashadapu1 year ago
Community Support
Hi DanSanDST , Thank you for reaching out to the Microsoft Community Forum.
We reproduced your setup and built a DAX calculated column that filters polygons by zone, groups edges by polygon, applies the ray-casting algorithm per group and returns the first polygon that contains the point. If none match, it returns Outside. This gives you exactly what you need, dynamically, without hardcoding.
Please check the attached .pbix file for reference.
That said, this approach won't scale well. DAX has no spatial engine and evaluating every polygon’s edges per point is expensive. For larger datasets, I recommend moving this logic to Power Query or a Fabric notebook, where spatial operations are more efficient and maintainable.
- DanSanDST1 year ago
Helper I
Thanks, ill test it once im home (my pc is faster).
I already was trying to solve it via Power Query and i managed to accomplish it (with some help from the community too). Its still taking on my PC about 15-20 mins to calculate for about 90k rows. Now im recalculating for some changes in the polygons area and its already on 23mins for 18k rows (a slower lapton, i5 gen 11 16gb ram).
- v-hashadapu1 year ago
Community Support
Hi DanSanDST , Thanks for the update and the information. Please do share your thoughts after checking it.
Thank you.