sum() Aggregate function doesn't add values properly

03-27-2020 09:14 AM
New Contributor III

I've created a survey that assists crop specialists with tracking counts of Cereal Leaf Beetle.  I have two parts to the survey: the first part that collects information regarding the field location, crop type, tillage, etc and the second part being a series of repeated questions related to the different stages of the crop based on the time of scouting and most importantly the observed counts.

As part of the first section of the survey, outside of the "repeat", I have an sum() aggregate function that acts as a running total. If I add multiple counts at the original time of data collection it works perfectly.  But the way I set this survey up is to allow the users to come back to the same field, multiple times throughout the growing season, and update their counts.  I've done this by enabling the Inbox and setting up my Repeats to allowAdds=true.  This is where my problem comes in.  When I add new counts, the sum() does not update to take in to account those recently adding values.  Only the latest counts are displayed in the sum fields.  They are not added to the totals

How do I trigger the sum() function to incorporate these newly added values?

Thank you for your assistance.

0 Kudos
1 Reply
Esri Esteemed Contributor

Hi Dan,

Without seeing the XLS file, I can't be sure, but this sounds like expected behavior since you are not loading the existing records via the Inbox.  When a form is loaded from the Inbox, questions with calculations have their value compared against the calculated value; if different, the calculation is disengaged from the question and the value retained.  This is done from the presumption that the existing value was manually input to override the calculation.  If you're loading the form without the previous values, the question with sum() will clearly not equal the sum() calculation (which would be 0).  There are a couple of ways to get the behavior (a running total) you want:

- load the existing repeats in by using the query keyword in the bind::Esri:parameters column along with the allowUpdates

- Generate the running total dynamically using Arcade via the FeatureSet functionality

0 Kudos