Select to view content in your preferred language

Pull value from question in repeat to parent, based on defined hierarchy

309
2
Jump to solution
04-04-2025 04:45 AM
jetemple
Occasional Contributor

Hello everyone,

I have a Survey123 form that is set-up to collect 'main' features as points, with a repeat to collect sub-features as a table - a parent-child relationship between the two.

The sub-features are all assigned a select_one value of 'High', 'Medium', 'Low', or 'None'.

I have a field in the parent feature section called 'Highest value present' - and was hoping there was a way to calculate/auto-populate this based on the 'Rating' values captured in multiple child sub-features, with a rule that High takes priority over Medium, over Low, over None.

For example, if a feature has three sub-features with ratings of Low, Medium, Low - I'm after it pulling the Medium value across.

I tried a basic if statement in the calculation field of the xlsform along these lines, hoping that the order would dictate the hierarchy:

if(${Rating}='High','High',if(${Rating}='Medium','Medium',if(${Rating}='Low','Low','None')))

But the calculated field in the parent layer defaults to the last repeat's value entered.

Is there any way to achieve this? Ultimately looking to keep the detail of the sub-features for reports etc., whilst assigning the highest value to the parent points for quick and easy mapping.

Thanks!

0 Kudos
1 Solution

Accepted Solutions
LaurenceTait
Frequent Contributor

Simplest trick will be to create calculate field within the repeat with the name rating_rank, and a value of: if(${Rating}='High','3',if(${Rating}='Medium','2',if(${Rating}='1'Low','0')))

Then outside the repeat create a hidden field with a name of max_rank, and a calculation value of :

max(${rating_rank})

That will pull the highest rating rank out of the repeat, You can then reverse the process, and generate the highest rating by creating a field called max_rating with a calculated value of

if(${max_rank}='3','High',if(${max_rank}='2','Medium',if(${max_rank}='3','Low','None')))

Note that since this calculation fires off the last value for rating entered, it will bug out of people scroll backwards though the repeats. Have a play around and check the behaviour, but you will probably want to set  the calculation mode to manual, or add a question that forces the user to update before scolling through the repeats.

View solution in original post

2 Replies
LaurenceTait
Frequent Contributor

Simplest trick will be to create calculate field within the repeat with the name rating_rank, and a value of: if(${Rating}='High','3',if(${Rating}='Medium','2',if(${Rating}='1'Low','0')))

Then outside the repeat create a hidden field with a name of max_rank, and a calculation value of :

max(${rating_rank})

That will pull the highest rating rank out of the repeat, You can then reverse the process, and generate the highest rating by creating a field called max_rating with a calculated value of

if(${max_rank}='3','High',if(${max_rank}='2','Medium',if(${max_rank}='3','Low','None')))

Note that since this calculation fires off the last value for rating entered, it will bug out of people scroll backwards though the repeats. Have a play around and check the behaviour, but you will probably want to set  the calculation mode to manual, or add a question that forces the user to update before scolling through the repeats.

jetemple
Occasional Contributor

This is absolutely perfect, thank you so much!

I found chucking a calculationMode=always in bind::esri:parameters sorts out things needing to be refreshed when jumping back and forth between repeats.

0 Kudos