Counting Instances of Repeat values

Hi,

I have a workflow in which I am names of teachers from 20 students using
repeat groups. We enter information about each student which includes who
their teacher is.
After looping through all 20 students, I want to find out how many students
each teacher has and pick out the top three teachers with the most students.
Any pointers on how I can achieve this?

Kind regards,

Sam

Sam,

There is no easy way of doing this.

You could put teachers in a select one, then used indexed-repeat() to
find the teacher values in each student. Then a lot of if() statements
that store a 1 if you match the known teacher.

Pseudo code would look like this:
student_1 = indexed-repeat(/data/students/teacher, /data/students, 1)
student_2 = indexed-repeat(/data/students/teacher, /data/students, 2)
teacher_a = sum(if(student_1 = teacher_a, 1, 0), if(student_2 =
teacher_a, 1, 0)...
teacher_b = sum(if(student_1 = teacher_b, 1, 0), if(student_2 =
teacher_b, 1, 0)...

Finding the top three is even messier. You could try using some
combination of max() or a ton of if() statements, but that sounds
painful. You could also list the results and maybe have the user pick
the top 3. Or just leave that as a server side calculation.

Yaw

ยทยทยท -- Need ODK services? http://nafundi.com provides form design, server setup, professional support, and software development for ODK.

On Sat, Aug 23, 2014 at 4:59 AM, Ruralnet Kalundu ruralnetkalundu@gmail.com wrote:

Hi,

I have a workflow in which I am names of teachers from 20 students using
repeat groups. We enter information about each student which includes who
their teacher is.
After looping through all 20 students, I want to find out how many students
each teacher has and pick out the top three teachers with the most students.
Any pointers on how I can achieve this?

Kind regards,

Sam

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.