Select to view content in your preferred language

Sum Area for unique records from Repeat

222
5
Jump to solution
11-28-2024 05:09 AM
MarkWILSON_LLS
Occasional Contributor

Gday there, 

Im setting up a form to assess groundcover at multiple sites across multiple reserves. 

Im currently using  a javascript function to create unique lists for concatenated text but I cant figure out a way to Sum an area field for unique Area values (ie I only want to sum the area for a reserve once, no matter how many points are associated with the reserve)

 

Is there a way that I can add a flag/trigger within the repeat whether the assessment point is the first entry for a reserve, so that I can use this as a filter for building the unique lists and sum fields in the parent table? I feel this should be possible using js but no amount of googling has found an example so far.

 

Form Structure looks like:

Repeat

- Assessment Location (geopoint)

- pulldata() for reserve attributes (Name, Area, Id etc)

- Assessment fields

- ?? Flag for unique values??

 

Summary (Parent)

- List of Unique Reserve Names (done)

- Sum of Unique Reserve Area 

- List of Unique Reserve ID's (done)

 

Many thanks.

mw

0 Kudos
2 Solutions

Accepted Solutions
abureaux
MVP Frequent Contributor

I'm probably missing something, but why not use a nested repeat?

E.g.,

abureaux_0-1733163133202.png

The general information is within the first (parent) repeat, and the dynamic information is within the second (nested) repeat. This is typically how you'd collect data with common fields, and allows for very easy transformation. However, like I previously mentioned, I may be missing something in the workflow here.

View solution in original post

MarkWILSON_LLS
Occasional Contributor

FYI, Managed a solution within js. 

  1. Create a list of all area values from repeat (using join())
  2. Create a unique list of area values from repeat (using unique.js)
  3. Convert string to array (using SumArray.js)

MarkWILSON_LLS_0-1733277994092.png

 

unique.js (adapted from https://community.esri.com/t5/arcgis-survey123-questions/challenge-question-looking-for-a-way-to-dis...)

MarkWILSON_LLS_2-1733278131751.png

 

 

SumArray.js

MarkWILSON_LLS_1-1733278092486.png

 

View solution in original post

0 Kudos
5 Replies
abureaux
MVP Frequent Contributor

Is this all within a single survey? If so, "area" should be in a parent table, and your "point data" in a nested repeat. That way the "area" is only collected once per location.

0 Kudos
MarkWILSON_LLS
Occasional Contributor

Thanks for the reply @abureaux 

Yes, its a single survey, 
The Parent level is a summary of the sites assessed in the repeat. 
- The repeats use pulldata() to pull in reserve details where the assessment is done (1:m). An expected result might be 30-50 assessment points carried out across 6 reserves to assess groundcover condition. 

Desired outcome

  • I'd like to create a concat field listing the 6 reserves (Achieved)
  • I'd like to Sum the area of the 6 Reserves (Using Sum(Repeat) i get the total sum of the assessments.)

 

Ive got 2 ideas on how to achieve this 

  1. Within the repeat - flag the first time a reserve is identified via the pulldata(@layer). Binary True/False

    Where flag = True, Use a Sum If query to Sum the area (Is it possible to do an If(,Sum(),)query from the child at the parent level?

  2. I'll build a Concat string of unique area values but not sure if it's possible to then get SVY to read this as an array and sum the total. ??

I could get the staff to do two repeats (1 to select reserves and 1 to conduct assessments but it is overkill when I can use the pulldata() functionality.

thanks

mw

0 Kudos
abureaux
MVP Frequent Contributor

I'm probably missing something, but why not use a nested repeat?

E.g.,

abureaux_0-1733163133202.png

The general information is within the first (parent) repeat, and the dynamic information is within the second (nested) repeat. This is typically how you'd collect data with common fields, and allows for very easy transformation. However, like I previously mentioned, I may be missing something in the workflow here.

MarkWILSON_LLS
Occasional Contributor

@abureaux , thankyou, I think this is the most logical process to follow. 

I was really hopeful for a .js sum unique array  or something similar but I totally get the simplicity in the structure of the nested repeats. 

I really appreciate your feedback. 

mw

0 Kudos
MarkWILSON_LLS
Occasional Contributor

FYI, Managed a solution within js. 

  1. Create a list of all area values from repeat (using join())
  2. Create a unique list of area values from repeat (using unique.js)
  3. Convert string to array (using SumArray.js)

MarkWILSON_LLS_0-1733277994092.png

 

unique.js (adapted from https://community.esri.com/t5/arcgis-survey123-questions/challenge-question-looking-for-a-way-to-dis...)

MarkWILSON_LLS_2-1733278131751.png

 

 

SumArray.js

MarkWILSON_LLS_1-1733278092486.png

 

0 Kudos