Division if (I want to run correct calculation of an average)


I want to run correct calculation of an average.
Example: the average of 1, 2, 0, 4, 5 is =1+2+0+4+5/4=3. Though, in Excel when you highlight 5 columns together the average in bottom will show 2.4 because it is divided by 5 not 4.

Question: is it possible in Kobo to run the calculation where while division “0” should not be counted. Meaning is it possible to do the following
${a}+${b}+${c}+${d}+${e} div “if” or “only” or I don’t know count()

Many thanks,

You could do it as outlined in the image shared below:

In the survey tab of your xlsform:

Data entry screen as seen in Enketo:

Reference xlsform:

Average (if-statement).xlsx (10.1 KB)

1 Like

Hi @Amriddin
You can also accomplish that using the following one-line calculation

(${Q1}+${Q2}+${Q3}+${Q4}+${Q5}) div ((IF(${Q1}>0,1,0))+(IF(${Q2}>0,1,0))+(IF(${Q3}>0,1,0))+(IF(${Q4}>0,1,0))+(IF(${Q5}>0,1,0))


1 Like