Forum Discussion
Azure Map Point ID, Order help
- 10 months ago
Hi unknown917,
The idea is that you want to rank the entries by distance, and then keep only the ones where rank = 1.
Something along the lines of this:
RankInBin = VAR sp = 'Table'[StartingPoint] VAR bin = 'Table'[DirBin] RETURN RANKX( FILTER( ALL('Table'), 'Table'[StartingPoint] = sp && 'Table'[DirBin] = bin ), 'Table'[DistanceKm], , DESC, DENSE )Next create a slim table of “farthest points” by filtering to RankInBin = 1:
OutlierPoints = FILTER( 'Table', 'Table'[RankInBin] = 1 )If you sometimes get multiple rows with the exact same max distance, add a secondary tiebreaker to the rank. One simple way is build a SortKey column and rank by that:
SortKey = 'Table'[DistanceKm] * 1000000 + (360 - 'Table'[BearingDeg]) / 1000
Then change the RANKX expression to use [SortKey] instead of DistanceKm, still DESC.If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.
Hi unknown917,
You’re basically trying to draw the “territory” around a start location. In geospatial terms, that’s a boundary around your farthest points (often approximated by selecting the farthest point in each direction and connecting them in order, or by computing a convex hull). The Azure Maps visual can show that boundary as a polygon if you give it geometry (e.g., WKT/GeoJSON) via a reference layer, or you can switch to a custom visual (like Icon Map) that accepts WKT directly.
Try this approach:
- Move “distance” and “bearing/direction” from measures to columns
You need row-level values to rank and sort points. Create calculated columns (or do it in Power Query) for:- DistanceKm (Haversine)
- BearingDeg (0–360 degrees from start > endpoint)
- DirBin (e.g., 16 bins of 22.5° each)
- Pick the outliers (one per direction bin)
Create a small table of only the farthest point per direction bin, per StartingPoint (use RANKX in DAX or a Group/Max step in Power Query). This eliminates duplicates naturally. - Build the polygon (WKT) by ordering points by bearing
Concatenate the ordered lon/lat pairs into a POLYGON((lon lat, ... , lon lat)) string (repeat the first coordinate at the end to close the ring). - Show it on a map
- Azure Maps: Add the polygon as a Reference layer (upload a CSV with the WKT column), or if your model produces WKT as a table, export it and use that CSV as the reference layer. The Azure Maps visual supports WKT/GeoJSON/KML/SHP via reference layers. See: Add a reference layer to Azure Maps.
If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.
tayloramy - I'm struggling with 2. how to create the table with the farthest points by direction, by starting point. I created a Variant table to get the data I need, but am not grasping how to use RANKX to produce a short list of lat/long by direction, by farthest point. Any guidance would be greatly appreciated.
- tayloramy10 months agoSuper User
Hi unknown917,
The idea is that you want to rank the entries by distance, and then keep only the ones where rank = 1.
Something along the lines of this:
RankInBin = VAR sp = 'Table'[StartingPoint] VAR bin = 'Table'[DirBin] RETURN RANKX( FILTER( ALL('Table'), 'Table'[StartingPoint] = sp && 'Table'[DirBin] = bin ), 'Table'[DistanceKm], , DESC, DENSE )Next create a slim table of “farthest points” by filtering to RankInBin = 1:
OutlierPoints = FILTER( 'Table', 'Table'[RankInBin] = 1 )If you sometimes get multiple rows with the exact same max distance, add a secondary tiebreaker to the rank. One simple way is build a SortKey column and rank by that:
SortKey = 'Table'[DistanceKm] * 1000000 + (360 - 'Table'[BearingDeg]) / 1000
Then change the RANKX expression to use [SortKey] instead of DistanceKm, still DESC.If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.