Survey 123 Pull Repeat data to Report Template

1186
11
05-09-2019 04:18 PM
Highlighted
New Contributor

Hi,

I want to pull specific data out of the repeat option for the word template, but it looks like it pulls every row at the moment.

For example, if have 3 repeats, it will pull photo description for all 3 loop.

${#Photograph}

${photo_description}

${/Photograph}

Lets say each description has a value, and the value is test1, test2, test3

In this case, if I used the command above, I would get this as return

test1

test2

test3

What I want is to only pull the value of test 2.  I want to be able to pull specific data I wanted on a specific loop.  No calculation, just values.

What I have right now is a bunch of photo and photo description in a repeat, and I want to be able to pull the pictures 1 at a time so I can setup the word template neatly.  Does that make sense?  Not sure if this is possible with survey123 template management at the moment.

Thanks,

Matthew

Tags (1)
Reply
0 Kudos
11 Replies
Highlighted
New Contributor III

Hi Matthew,

I'm not sure how to pull individual datum from one of a set of repeats, but if you're trying to format repeat photos neatly in a report see my attached template as an example. (One difference from yours, I think,: I didn't include the "photo description" in the survey as my staff prefer to type that in once they get the word document report, but there's no technical reason it couldn't be done.)

Chris

Reply
0 Kudos
Highlighted
Regular Contributor

One thing that might help is to add within your repeat a photo question for each of the photos; in your case Photo1, Photo2, and Photo3, as this is will start the name of the photo with each of those names.

Then within the Custom Report Template you might be able to use a conditional statement for where you want each of the photo1, photo2, and photo3 is placed within the template. You could even add in some coding to keep or force the size of the photo within each of the boxes or area that you would like to have the photos placed. Then underneath each of the photos you could pull your description.

Hope this helps you out!

Cheers,

Mike

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Matthew,

One possibility would be to use a conditional statement to only show the data of a repeat when there is a certain value - refer to teh conditional elements section in Feature report templates—Survey123 for ArcGIS | ArcGIS . If you're wanting to get something like 'the second repeat', that is a bit harder - you would want to have a hidden field with a calculation of once(count(${q}) + 1) where ${q} is a question in the repeat - that will let you store an index of the repeat.

Reply
0 Kudos
Highlighted
New Contributor II

Hi James, 

Once I have the once(count()+1) set up, what is the syntax to reference a specific count in my report? 

Thank you!

Jen

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Jennifer,

You would access it using whatever field name it is in the report, just like any other field - it works the same as every other field/question.

Reply
0 Kudos
Highlighted
New Contributor II

Sorry James, my question was overly ambiguous.

Currently I have my feature report set up to pull from my repeats as ${#Survey_1}${field_name}${/Survey_1} but the output I get there is all 40 of the repeat answers for field_name. I'm trying to pull out the information for repeat 1, then repeat 2, then repeat 3, etc to create a report that reads consecutively across each repeat rather than an aggregate of all 40 repeats in each field.

I implemented the once(count()+1) row that you suggested above, and I can see the row works perfectly in the exported xlsx but can't figure out how to use it to reference the fields from the rest of that row of data for the feature report. Can you provide an example of the syntax I would use to do this?

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Jennifer,

It sounds like you want to make the repeat section larger than just one field at a time. Within the ${#Survey_1}${/Survey_1} section you can have whatever formatting you want, allowing you to create a mini-section within the report that includes multiple fields, tables, etc.  You can also use the repeat section at the start/end of a table row to print the repeats in a table.

Reply
0 Kudos
Highlighted
New Contributor II

Hi James, 

Yes, my repeat section is larger than one field. What I have currently in my survey is a set of non-repeat questions, and then repeats:

select_one District

eval_date

begin repeat                     Survey_1

testrep

autofill                               once(count(${testrep})+1) 

field_1

field_2

field_3

end repeat 

That section has a count of 40 to repeat across 40 assessment areas. What I'm trying to accomplish is a feature report template that can be auto-generated by Integromat once the 40th count is completed. I need the report to present the data in each individual assessment, so if the answers at assessment #1 are Spruce, healthy, 100%, and the answers at assessment #2 are Pine, diseased, 20%, I want to have a feature report that says 

   Sample Assessment in District 5

   Date: 1/24/2020

   Sample 1: Spruce

   Status: Healthy

   Intact Bark: 100%

   Sample 2: Pine

   Status: diseased

   Intact Bark: 20%

When I set my template up, it looks like this: 

   Sample Assessment in ${District}

   Date: ${eval_date}

   Sample ${autofill}: ${#Survey_1}${field_1}${/Survey_1}

   Status: ${#Survey_1}${field_2}${/Survey_1}

   Intact Bark: ${#Survey_1}${field_3}${/Survey_1}

   Sample ${autofill}${#Survey_1}${field_1}${/Survey_1}

   Status: ${#Survey_1}${field_2}${/Survey_1}

   Intact Bark: ${#Survey_1}${field_3}${/Survey_1}

But my output looks like this: 

   Sample Assessment in District 5

   Date: 1/24/2020

   Sample 1 2: Spruce Pine

   Status: Healthy diseased

   Intact Bark: 100% 20%

   Sample 1 2: Spruce Pine

   Status: Healthy diseased

   Intact Bark: 100% 20%

I'm having an easy enough time finding the data using the query function with ${field_1} where ${autofill}=2, so it seems possible, I just can't get the syntax right to pull it into a feature report for automation. 

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Jennifer,

Taking the template code you posted above as a sample, here's how I would alter to produce what your are specifying:

----------------------------------------

   Sample Assessment in ${District}

   Date: ${eval_date}

   ${#Survey_1}

   Sample ${autofill}: ${field_1}

   Status: ${field_2}

   Intact Bark: ${field_3}

   ${/Survey_1}

----------------------------------------

Note that the repeat section is treated more like a block of text, with multiple fields specified within it.