Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi Community
I'm trying to figure out if this is even possible in DAX = calculating the area and perimeter of polygons in DAX .
Eventually I would love to see if one can calculate a long axis and minor axis of a polygon, but area and perimeter would be a major win.
Here is my test data set:
PolygonOrderX Y
Armada | 0 | 1133.867302 | 9377.688859 | |
Armada | 1 | 1133.885225 | 9377.708789 | |
Armada | 2 | 1133.911246 | 9377.708524 | |
Armada | 3 | 1133.931606 | 9377.731125 | |
Armada | 4 | 1133.959339 | 9377.716192 | |
Armada | 5 | 1133.957758 | 9377.703479 | |
Armada | 6 | 1133.932689 | 9377.703266 | |
Armada | 7 | 1133.924513 | 9377.694315 | |
Armada | 8 | 1133.89474 | 9377.690248 | |
Armada | 9 | 1133.886501 | 9377.681242 | |
Armada | 10 | 1133.867302 | 9377.688859 | |
Barbaras | 0 | 1133.940272 | 9377.685785 | |
Barbaras | 1 | 1133.924513 | 9377.694315 | |
Barbaras | 2 | 1133.89474 | 9377.690248 | |
Barbaras | 3 | 1133.886501 | 9377.681242 | |
Barbaras | 4 | 1133.898729 | 9377.674412 | |
Barbaras | 5 | 1133.909019 | 9377.674985 | |
Barbaras | 6 | 1133.940272 | 9377.685785 | |
Coconuss | 0 | 1133.956245 | 9377.691305 | |
Coconuss | 1 | 1133.940272 | 9377.685785 | |
Coconuss | 2 | 1133.924513 | 9377.694315 | |
Coconuss | 3 | 1133.932689 | 9377.703266 | |
Coconuss | 4 | 1133.957758 | 9377.703479 | |
Coconuss | 5 | 1133.956245 | 9377.691305 | |
Descripta | 0 | 1133.867302 | 9377.688859 | |
Descripta | 1 | 1133.842369 | 9377.696331 | |
Descripta | 2 | 1133.869321 | 9377.753337 | |
Descripta | 3 | 1133.911591 | 9377.742598 | |
Descripta | 4 | 1133.922642 | 9377.73665 | |
Descripta | 5 | 1133.931606 | 9377.731125 | |
Descripta | 6 | 1133.911246 | 9377.708524 | |
Descripta | 7 | 1133.885225 | 9377.708789 | |
Descripta | 8 | 1133.867302 | 9377.688859 | |
Eliptica | 0 | 1133.955761 | 9378.00986 | |
Eliptica | 1 | 1133.953292 | 9377.997504 | |
Eliptica | 2 | 1133.932773 | 9377.974711 | |
Eliptica | 3 | 1133.921109 | 9377.981121 | |
Eliptica | 4 | 1133.933362 | 9377.994733 | |
Eliptica | 5 | 1133.931604 | 9378.002572 | |
Eliptica | 6 | 1133.94595 | 9378.018399 | |
Eliptica | 7 | 1133.955761 | 9378.00986 |
(Order is the vertice number and needs to be in that order)
Or if this is not possible directly in DAX, whether anyone has the skills in doing this in Python during data load in PQ. I'm thinking shapely ? I've tested the below code and it gives the same (very close at least) to what I get from my 3D modelling package
from shapely.geometry import Polygon
coords = ((-1, 0), (-1, 1), (0, 0.5), (1, 1), (1, 0), (-1, 0))
polygon = Polygon(coords)
polygon.length
And then using polygon.length and polygon.area to give area and perimeter, but I'm not sure how to get this to run through the complete table of polygons and export the list on unique polygons with their respective areas and perimeters through Power Query.
thanks heaps in advance for any pointers
Cheers
Manfred
Hi @mwimberger ,
Sorry for that we just can calculate the length of each point and get the perimeter of polygon.
You can refer the following steps.
1. We need to create two calculate columns to get the next row value.
x1 = CALCULATE(SUM('Table'[x]),FILTER('Table','Table'[Polygon]=EARLIER('Table'[Polygon]) && 'Table'[Order]=EARLIER('Table'[Order])+1))
y1 = CALCULATE(SUM('Table'[y]),FILTER('Table','Table'[Polygon]=EARLIER('Table'[Polygon]) && 'Table'[Order]=EARLIER('Table'[Order])+1))
2. Then we can create a new column to get the length of each line.
Length =
var x = POWER([x1]-[x],2)
var y = POWER([y1]-[y],2)
var z = SQRT(x+y)
return
IF(ISBLANK([Column]),BLANK(), z)
Column and Column 2 are the auxiliary column.
3. At last we can create a table visual, put the polygon name and length in it to get the result like this,
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
Or if you have other better solutions, please share them for more people to see and let us learn from each other.
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
65 | |
64 | |
56 | |
39 | |
27 |
User | Count |
---|---|
85 | |
59 | |
45 | |
43 | |
38 |