AnsweredAssumed Answered

CountIf equivalent for Survey123

Question asked by MondiSA on Mar 4, 2020
Latest reply on Aug 5, 2020 by MondiSA

I have a survey where I am capturing the height of trees in a repeat, and then later on in the survey, I calculate the average height of these trees and then the values for 20% above the mean, and 20% below the mean. Now I need to do a count of the number of trees that are more or less than 20% above/below the mean. 


Is this at all possible?


I have tried using the logic of


if(${height} > ${top_from_mean}, '1', if(${height} < ${lower_from_mean},'1', '0'))


inside the repeat, but this seems to write a static value to the field in the order that the data is captured, rather than a dynamic value that calculates as the average and top_from_mean values update. If I put that calc outside of the repeat it won't do the calc on the individual values and I won't get a count. 


Any suggestions? Would it be easier to do this in Arcade on the data after it is submitted? We did want to present the results as the survey is completed to pass/fail the sample plot.