Hello, I am new to arcade and have been having some trouble with creating a table. This is my first post, as well, so if I’m missing something or going about this the wrong way, let me know. I have line features that contain fields for diameter and length. I want to create a table that sums up the length by diameter. For example, the total length of pipes with a 4 inch diameter is 2,000 ft. I’d like to write code that creates a table with all of the diameters on the left and the sum of the pipe lengths for that diameter on the right.
I haven’t been able to find similar cases like this online and I feel like I’ve just hit a wall. I tried a script that an AI suggested, but have just been getting vague syntax errors when attempting. Does the code that it suggests make sense?
When asking a question about code, please the code editor instead of a image of the code.
You can use the GroupBy function to do this type of summary. You code would look something like this
var fs = FeatureSetByPortalItem(Portal("your portal"), "itemId", 0, ["PipeDiameterField", "PipeLengthField"], false);
GroupBy(fs, ["PipeDiameterField"], { name: "Length", expression: "PipeLengthField", statistic: "SUM" })
That function is built into the Table elements in ArcGIS Online dashboards without any code.
Just select the Grouped values, set the field you want to group by as the Category field, choose "Sum" and the value/sort fields.
R_