Select to view content in your preferred language

Feature Report nested repeat unique values

448
7
02-02-2026 04:05 AM
SCB
by
Occasional Contributor

Hello!

I am struggling with the syntax for a Feature Report template.  My Feature Report is linked to a Feature Layer, and the Feature Layer structure is represented below:

Field_1Field_2Field_3Field_4

A1

Name_A1

I1

Description_I1

A1

Name_A1

I2

Description_I2

A2

Name_A2

I3

Description_I3

A2

Name_A2

I4

Description_I4

A2

Name_A2

I5

Description_I5

 

I need to perform nested repeats starting with the outer repeat of Field_1 (extracting unique values); then the inner repeat will be based on Field_3.

So, schematically, the output will look something like:

A1Name_A1

 

I1Description_I1

 

I2Description_I2

 

A2Name_A2

 

I3Description_I3

 

I4Description_I4

 

I5Description_I5

 

Any thoughts on the required syntax to achieve this type of flow?

Cheers

SCB

Tags (1)
0 Kudos
7 Replies
TylerGraham2
Frequent Contributor

Check out the documentation on nested repeats in the report template.  Repeat expressions—ArcGIS Survey123 | Documentation

You'll probably need to play around with the exact placement of where you call and close the repeats.  Sometimes it likes it outside the table, sometimes at the beginning of the table, and sometimes in the table where you start calling data. If you're looking for a seamless table in your report that iterates through all the repeats using the first repeat table, I'd try calling the repeats inside the table at the beginning.  

Assuming Field 1 and Field 2 are in the first repeat table, Field 3 is in the 2nd repeat, and Field 4 is in the 3rd repeat you'd want it looking like this.  Opening and closing the repeat in the table adds more rows to the table for each record in the table, which should be based off of Repeat1 in this example.

${Repeat1}${Repeat2}${Repeat3}Field_1Field_2Field_3Field_4

${Repeat1.field1}

${Repeat1.field2}

${Repeat2.Field3}

${Field4}${/}${/}${/}

 

0 Kudos
SCB
by
Occasional Contributor

Thanks.  It's not the placement I'm so worried about (think I have a good handle on that), but the actual syntax required.

The outer repeat needs to be based on unique values in Field_1, whilst the inner repeat needs to somehow reference the current value of the outer repeat to get the correct features for (in this example) Field_3 and Field_4.

Cheers

SCB

0 Kudos
TylerGraham2
Frequent Contributor

If the tables are in nested relationships in the feature service (e.g. feature layer > table 1 >table 2> table 3) then the source I mentioned earlier is way to go because there is direct path via the relationships. 

If you have multiple tables in the feature service with relationships in parallel (e.g. feature layer > table 1; feature layer > table 2; feature layer > table 3) then you will still need to use the directions for nested repeats in the template, but you will also need to do some work with conditional statements in the template too since there isn't a direct flow relating all the tables.  

Conditional report elements—ArcGIS Survey123 | Documentation

0 Kudos
SCB
by
Occasional Contributor

The data is in a single feature layer as described above.  The first table in my original post is a schematic of the feature layer attribute table.  The further tables show how the report output needs to look like.  Appreciate I may need a conditional statement but it is based on the current field_1 value of the outer repeat and I don't know how to access this variable in this fashion.

Cheers

SCB

 

0 Kudos
TylerGraham2
Frequent Contributor

Ah, ok. You're using some incompatible terminology.  A repeat in Survey123 uses related tables which was why I was pointing towards repeat expressions.  The individual report template has no "for" conditional statements, so you can't do what you're trying to do unless your feature service schema was different and used feature layers and related tables.  

It might be possible to get in the neighborhood with a Summary report template. Survey123 Tricks of the Trade: Summary sections in... - Esri Community

Neal_t_k
MVP Regular Contributor

@SCB This is a tricky one being all in one table.  If Field 1 and Field 2 were in the main table and Field 3 & 4 were in a repeat table it would be easier.

Since it is all in one you will need to use a summary report. https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-summary-sections-i... When you run the report you will have to include all, or select all the entries you want included.

Reports have a "groupby" function but it only works for stats, so to get a "grouping" by Fields 1 and 2, you can implement some of the methods here:https://doc.arcgis.com/en/survey123/browser/analyze-results/featurereportqueries.htm. (Also look at the syntax for where clauses in this link in the additional syntax section)

The following should get you the format for the list you want returned:

$<$summary>
${#survey | outFields:"Field_1, Field_2" | returnDistinctValues:"true" | orderByFields:"Field_1, Field_2"}
###########${Field_1} - ${ Field_2}
${#survey | where:"Field_1='"+Field_1+"' AND Field_2='"+ Field_2+"'" | orderByFields:"Field_3"}
_________${Field_3}: ${Field_4}
${/}
${/}
$</>

You are going to have to play with it to get it in your table format. The "#####" and "____" are just for visualization, they can go after you verify the results.

SCB
by
Occasional Contributor

This was causing me too many headaches, so I have adjusted the template to make life easier for myself.

Cheers

SCB

0 Kudos