Averaging multiple values

142
1
Jump to solution
06-14-2021 01:12 PM
JoshuaVickrey
New Contributor

My form allows users to put in a depth value (decimal) for each station (text box) they assign (max of 40 stations).  I need to be able to calculate the average of the total depth.  In my attached image, you can see I'm using an IF statement to determine how many stations they provided a value for so that I can divide that number by the total depth BUT the average is not dynamically showing as they add another station.  Can someone let me know what is wrong with my logic or if there is a better way?  Thank you in advance

 

 

0 Kudos
1 Solution

Accepted Solutions
JamesTedrick
Esri Esteemed Contributor

Hi @JoshuaVickrey ,

The situation you are describing is normally best handled by using a repeat to record the observations.  Based on the image of the form, it looks like the repeat would have 3 questions - depth, station and offsetROW .  This would reduce the calculation for the average value to sum(${depth}) div count(${depth}) (sum over number of records).

Within your existing calculation, note that empty depth questions are interpreted as NaN (not a number) and prevent completion of the denom ques....  This can be avoided by providing a default value or using the coalesce() function to provide a value when empty.

View solution in original post

0 Kudos
1 Reply
JamesTedrick
Esri Esteemed Contributor

Hi @JoshuaVickrey ,

The situation you are describing is normally best handled by using a repeat to record the observations.  Based on the image of the form, it looks like the repeat would have 3 questions - depth, station and offsetROW .  This would reduce the calculation for the average value to sum(${depth}) div count(${depth}) (sum over number of records).

Within your existing calculation, note that empty depth questions are interpreted as NaN (not a number) and prevent completion of the denom ques....  This can be avoided by providing a default value or using the coalesce() function to provide a value when empty.

View solution in original post

0 Kudos