# Counting intake types and displaying on follow up form

**URL:** <https://forum.dimagi.com/t/counting-intake-types-and-displaying-on-follow-up-form/3656>\
**Category:** Users\
**Created:** [August 4, 2017, 8:02pm UTC](https://forum.dimagi.com/t/counting-intake-types-and-displaying-on-follow-up-form/3656 "2017-08-04T20:02:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexandra\_Hinton](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@Alexandra\_Hinton](https://forum.dimagi.com/u/Alexandra_Hinton)\
**Post date:** [August 4, 2017, 8:02pm UTC](https://forum.dimagi.com/t/counting-intake-types-and-displaying-on-follow-up-form/3656/1 "2017-08-04T20:02:34Z")

</div>

I'm wondering how to display the number of intake forms we have for an  
individual by type in their follow up form (each suicide attempt, ideation,  
etc. over time gets its own intake form).

So, for example, when our case worker goes to visit someone for a follow up  
visit, they would be able to see how many attempts the individual has made  
(that are in our registry).

I see code for counting forms (coalesce(#case/visit\_count, 0) + 1) but it  
doesn't allow me to count by type.

Thanks!

---

<div class="post-metadata">

**Author:** ![Alexandra\_Hinton](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@Alexandra\_Hinton](https://forum.dimagi.com/u/Alexandra_Hinton)\
**Post date:** [August 4, 2017, 8:03pm UTC](https://forum.dimagi.com/t/counting-intake-types-and-displaying-on-follow-up-form/3656/2 "2017-08-04T20:03:42Z")

</div>

Oh! Forgot to mention. Intake type is determined by a checkbox variable on  
the intake form.

---

<div class="post-metadata">

**Author:** ![Clayton\_Sims](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/clayton_sims/32/496_2.png) [@Clayton\_Sims](https://forum.dimagi.com/u/Clayton_Sims)\
**Post date:** [August 4, 2017, 9:44pm UTC](https://forum.dimagi.com/t/counting-intake-types-and-displaying-on-follow-up-form/3656/3 "2017-08-04T21:44:34Z")

</div>

Hi Alexandra,

To accomplish this the easiest thing to do is to keep an explicit count for  
each visit type by maintaining one hidden value calculation and variable  
for each potential type.

For each hidden value you, you'd replace that calculation with something  
like the following (which assumes there is a select question in the form  
with the id _type\_of\_intake_

(coalesce(#case/visit\_count\_ideation, 0) +  
if(selected(#form/type\_of\_intake, 'ideation'), 1, 0) )

-Clayton

> **···**
>
> On Fri, Aug 4, 2017 at 4:03 PM, Alexandra Hinton wrote:
> 
> > Oh! Forgot to mention. Intake type is determined by a checkbox variable on  
> > the intake form.
> > 
> > --  
> > 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](mailto:commcare-users+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
