Summarize table in arcade for Popup

381
10
03-05-2021 07:39 AM
Labels (2)
aroininen
New Contributor III

Hello Again folks,

I feel I may be exhausting  my question limit - much appreciation to the community - I am looking into a course.

I'm trying to summarize a field in arcade and get statistics from the  other fields for a result similar to this:

aroininen_0-1614958119661.png

Is this possible in Arcade?

I have looked a Paul Bakers post and the Spanish one and many others but I just can't seem to make anything work

I think Groupby is the option but I just don't know get the sums from the other fields

also do I need to use intersect as I want to get results from the whole dataset if so I can intersect with the municipal border as all developments are within

 

I got this far with this expression (excuse the radon variables!):

aroininen_1-1614958519344.png

var intersectArea = Intersects(FeatureSetByName($map,"Planning_Layers - Development Applications"), $feature)
var treeList = groupBy(intersectArea, "PRStatus",
{name:"count", expression:"PRStatus" , statistic:"COUNT"})

var topFeatures = Top(OrderBy(treeList, "count desc"),10)

var treeList = ''
for (var topFeature in topFeatures) {

treeList += topFeature.PRStatus + " (" + topFeature.count + ")" + TextFormatting.NewLine

}
return treeList

 

Thanks again

Aaron

Tags (3)
0 Kudos
10 Replies
aroininen
New Contributor III

Hello Again,

I had a bit of a break though I am able to display total units by Status with this expression!:

Problem is if I keep adding more fields for statistics (i.e Semi, Row)  the result is always the last Groupby

I tried editing the  last statement to add more stats to result but I get nothing

 

here is the expression I am using:

I don't need to order this but if I remove it doesn't work that why I just use top 10

var planstat = FeatureSetByName($map,"Planning_Layers - Development Applications - master", ['PRStatus', 'Units', 'SingleD'], false)
var treeList = groupBy(planstat, "PRStatus",
{name:"count", expression:"PRStatus" , statistic:"COUNT"})
var treeList = groupBy(planstat, "PRStatus",
{name:"count", expression:"Units" , statistic:"SUM"})

 


var topFeatures = Top(OrderBy(treeList, "count desc"),10)

var treeList = ''
for (var topFeature in topFeatures) {

treeList += topFeature.PRStatus +" (" + topFeature.COUNT + ")"+ TextFormatting.NewLine

}
return treeList

If I get this last bit figured out that would be great but I can live with what I have too

Thanks again community!

 

0 Kudos