Is it possible to use max, min, and sum in forms outside of repeats?

Hi all - I'm trying to find the max value of three integers entered in a form. According to the docs (https://docs.getodk.org/form-operators-functions/#max), this can be accomplished by calling the max() function on a nodeset consisting of the three integer values. The docs specify that nodesets can be created by joining nodes with the | operator.

As a result, I attempted to call max(${int1} | ${int2} I ${int3}) - however, this throws an error during form validation. For more details, see this thread Getting a nodeset of responses, but not from a repeat group. This error occurs regardless of whether you use full XPath notation or the ${} notation.

I also tried to put the three integer questions inside of a group, and then call max(${group_of_ints}). This clears validation, but returns nothing. This same issue appears to apply to min() and sum() as well.

Is there some other way of joining nodes together in order to create a nodeset? Failing that, is there some other way to use max() in this way?

For anyone else in the future who has this problem, these functions can be called in the form of max(${int1}, ${int2}, ${int3}), without bothering with joining nodes in the way described in the docs.

Thanks to Grzegorz for the solution - Getting a nodeset of responses, but not from a repeat group - #3 by Grzesiek2010

1 Like