Incrementing a counter for attendance

I have an attendance form which asks for the training session and whether
the participant was present. I’ve added case properties for each session
which gives a 1 if the participant is present and a 0 if not, with a
display condition so that each one only does the calculation for the
correct session. What I’d like to do is have CommCare create a sum of all
of these case properties to give the total number of sessions each
participant attended.

This comes close to what I’m looking
for: https://wiki.commcarehq.org/display/commcarepublic/Incrementing+a+counter.
However, there are often duplicate forms filled out for each participant -
for example, if she is absent for the training in her village, but attends
one in a neighboring village the next day, there will be two attendance
forms submitted.

Is this possible?

Thanks!

Eric,

If the value that’s ‘1’ if the participant is present and ‘0’ if not is
stored at reference #form/present’ (for example) then you could replace the
calculation from the documentation with the calculation:

if(#form/present = ‘1’, coalesce(#case/visit_count, 0) + 1,
coalesce(#case/visit_count))

So that the count will only increment if the participant is present.

Cheers,
Will

··· On Thu, Nov 3, 2016 at 2:02 AM, Eric Jospe wrote:

https://wiki.commcarehq.org/display/commcarepublic/Incrementing+a+counter

Thanks, Will! This would work some of the time, but we do get many
duplicate forms submitted for a variety of reasons (we’re working on
it…), so if that happens it would make the counter inaccurate. But in the
absence of a way of summing case properties from different forms, I will
definitely give this a shot and keep track of the number of duplicate forms
sent.

Cheers,

-Eric

··· On Thu, Nov 3, 2016 at 3:54 PM, William Pride wrote:

Eric,

If the value that’s ‘1’ if the participant is present and ‘0’ if not is
stored at reference #form/present’ (for example) then you could replace the
calculation from the documentation with the calculation:

if(#form/present = ‘1’, coalesce(#case/visit_count, 0) + 1,
coalesce(#case/visit_count))

So that the count will only increment if the participant is present.

Cheers,
Will

On Thu, Nov 3, 2016 at 2:02 AM, Eric Jospe eric.jospe@gmail.com wrote:

https://wiki.commcarehq.org/display/commcarepublic/Incrementing+a+counter


You received this message because you are subscribed to a topic in the
Google Groups “commcare-users” group.
To unsubscribe from this topic, visit https://groups.google.com/d/
topic/commcare-users/o7Ngl6bt298/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.