Counting a field from a related table - Pop ups

321
1
08-16-2022 10:31 AM
ScottStepro1
New Contributor III

Hello all, new to arcade and while I have some experience working with related tables, I can not for the life of me figure out how to count the records by individual fields.

I have a series of numeric fields in a solid waste survey that I would like to count by response.  Fields are numeric with 1 = yes and 0 = no (0).  I'd like to count and display each fields totals in popup. 

Field name example would be

  1. BWCnt.  Bulky Waste Items
  2. RecCnt - Recyclables

etc...

Thanks in advance!

Tags (3)
0 Kudos
1 Reply
JohannesLindner
MVP Frequent Contributor

You can use Sum() for that.

// get the related table
var related = FeatureSetBy*(...)

// build the popup lines
var popup_lines = [
    "Bulky Waste Items: " + Sum(related, "BWCnt"),
    "Recyclables: " + Sum(related, "RecCnt"),
]

// conacatenate and return
return Concatenate(popup_lines, TextFormatting.NewLine)

Have a great day!
Johannes
0 Kudos