Select to view content in your preferred language

Calculations in repeats not updating

228
5
Jump to solution
Monday
Labels (1)
SébastienDebar
Emerging Contributor

I have an inspection form with repeat. The repeat in the survey contains two questions. The first is about the presence of trees, and the second is about the number of trees (if the first question is Yes). In the repeat, I have a field that takes the value of the second question (if the first question is Yes), otherwise it takes the value 0. I have another field that sums up all the trees.

typenamelabelcalculationrelevantbind::esri:parameters
begin repeatTree<center>Tree   
select_one yes_noTrees_PresentPresent of trees :   
integerTrees_NumberTrees : ${Trees_Present} = 'yes' 
integerTrees_TotalTotal :if(${Trees_Present} = "yes", ${Trees_Number}, 0) calculationMode = always
end repeat     
      
integerAll_TreesTotal trees :sum(${Trees_Total}) calculationMode = always


When users were filling out the survey recently, they noticed that moving back and forth between repeats to make corrections locked the calculations and the totaled sums could no longer be updated. I have tried calculationMode = always.

SbastienDebar_0-1750683224935.png

 

I am using Survey123 version 3.22.49.

0 Kudos
1 Solution

Accepted Solutions
abureaux
MVP Frequent Contributor

abureaux_0-1750703359512.png

This "refresh" button indicates that either someone typed into the field, or something more annoying is going on (could be a few vague things...). Clicking the button should show the correct values.

  1. Calculated fields should be hidden or locked. This prevents users from interfering with them. Locked/hidden calculates also tend to work better than visible and unlocked calculations. 

  2. Repeats are annoying for calculations. In very general terms, when the last thing in a repeat is a number needed for a calculation, the user needs to manually press "enter" for the calculation to trigger. Entering the value and then immediately going to the next tab skips that step and required them to go "back" and then "forward" in the repeat for the calculate to work. A more elegant solution is to use the "numbers" appearance. This does everything for you, ensuring the value is entered and the calculate triggers. 
    abureaux_1-1750703669341.png

  3. ${Trees_Total} is unnecessary for the survey as-is. You can drop it entirely and save the hassle. 
    abureaux_2-1750704082674.png

  4. <calculationMode=always> should not have spaces. Spaces means it isn't working. 
  5. This will have zero impact on your calculations, but I always like mentioning it. Swapping <${Trees_Present} = 'yes'> to <selected(${Trees_Present},'yes')> is a good practice. Far more flexible. In this case, they will have the same effect.

Try some of the things I have listed above. There are probably a few things on their own that will resolve the issue. But there are several "best practices" that should not only fix that issue, but prevent future issues as well.

View solution in original post

5 Replies
Neal-Kittelson
Frequent Contributor

I don't remember repeats being locked down if it is the same session but, Take a look at this documentation about editing repeats.   Also did they "tab" off the question or some other commit prior to jumping back and forth between repeats? 

https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-download-survey-da...

on the begin repeat question in the bind::esri:parameters column, put query allowUpdates=true

0 Kudos
SébastienDebar
Emerging Contributor

I set query allowUpdates=true, but I get the same problem.

The field that takes the value of the second query doesn't recalculate even if I validate the change to the second query.

0 Kudos
Neal-Kittelson
Frequent Contributor

Try this:

NealKittelson_0-1750697327954.png

Not sure why the way you had it setup didn't work?

SébastienDebar
Emerging Contributor

It makes no difference, on the Connect or on my phone. 

Capture d’écran 2025-06-23 130922.png

0 Kudos
abureaux
MVP Frequent Contributor

abureaux_0-1750703359512.png

This "refresh" button indicates that either someone typed into the field, or something more annoying is going on (could be a few vague things...). Clicking the button should show the correct values.

  1. Calculated fields should be hidden or locked. This prevents users from interfering with them. Locked/hidden calculates also tend to work better than visible and unlocked calculations. 

  2. Repeats are annoying for calculations. In very general terms, when the last thing in a repeat is a number needed for a calculation, the user needs to manually press "enter" for the calculation to trigger. Entering the value and then immediately going to the next tab skips that step and required them to go "back" and then "forward" in the repeat for the calculate to work. A more elegant solution is to use the "numbers" appearance. This does everything for you, ensuring the value is entered and the calculate triggers. 
    abureaux_1-1750703669341.png

  3. ${Trees_Total} is unnecessary for the survey as-is. You can drop it entirely and save the hassle. 
    abureaux_2-1750704082674.png

  4. <calculationMode=always> should not have spaces. Spaces means it isn't working. 
  5. This will have zero impact on your calculations, but I always like mentioning it. Swapping <${Trees_Present} = 'yes'> to <selected(${Trees_Present},'yes')> is a good practice. Far more flexible. In this case, they will have the same effect.

Try some of the things I have listed above. There are probably a few things on their own that will resolve the issue. But there are several "best practices" that should not only fix that issue, but prevent future issues as well.