Adding cumulative values

I wanted to add the cumulative total of drugs sent to a health facility.
For example:

1.) on day-1, 10 paracetamol packs were sent to the facility. On the case
detail, I want to display Total to-date = 10 packs
2.) on day-2, another 20 paracetamol packs are sent. now Total to-date =
30 packs

3.) on day-3, 5 packs are sent. Total to-date = 35 packs… etc.

How can I do this using CommCare? I tried the coalesce function but it
didn’t work.

Thanks!

Brian,

Can you describe a bit more about how you’ve set this up in your app?

the basic structure of this would look like:

  • The form has two hidden values inside
    • *total_to_date_previous *<- Loaded as a default value from the case
    • *total_to_date *<- Set to a calculation that is roughly:
      if(total_to_date_previous
      = ‘’, 0, total_to_date_previous) + new_additions
  • The form saves *total_to_date *to the total_to_date case property,
    and loads the total_to_date case property into the
    total_to_date_previous node.

Is this similar to how things are configured currently?

··· On Sat, Aug 6, 2016 at 2:05 PM, Brian wrote:

I wanted to add the cumulative total of drugs sent to a health facility.
For example:

1.) on day-1, 10 paracetamol packs were sent to the facility. On the case
detail, I want to display Total to-date = 10 packs
2.) on day-2, another 20 paracetamol packs are sent. now Total to-date =
30 packs

3.) on day-3, 5 packs are sent. Total to-date = 35 packs… etc.

How can I do this using CommCare? I tried the coalesce function but it
didn’t work.

Thanks!


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