# We need help

**URL:** <https://forum.dimagi.com/t/we-need-help/2209>\
**Category:** Users\
**Created:** [May 16, 2015, 4:20am UTC](https://forum.dimagi.com/t/we-need-help/2209 "2015-05-16T04:20:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tewelde\_Aregawi](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/t/8c91f0/32.png) [@Tewelde\_Aregawi](https://forum.dimagi.com/u/Tewelde_Aregawi)\
**Post date:** [May 16, 2015, 4:20am UTC](https://forum.dimagi.com/t/we-need-help/2209/1 "2015-05-16T04:20:43Z")

</div>

we are developing Household survey apps.we have created repeat group that  
registers all people leaving with in the household head including their  
age and sex. From this we need to store all woman with age range 15 and  
59,all men with age range 15 and 49 and all children under 5 in hidden  
value from the repeat group automatically without asking the household  
head again.

To do this we have created hidden values and set the calculate condition  
as shown below

prev\_men\_aged\_15\_and\_59 = coalesce(/data/men\_aged\_15\_and\_59, 0)

prev\_woman\_aged\_15\_and\_59 = coalesce(/data/woman\_aged\_15\_and\_59, 0)

men\_aged\_15\_and\_59 = if(/data/Register\_peoples\_live/sex\_name = "male"  
and /data/Register\_peoples\_live/age\_name \>=15 and  
/data/Register\_peoples\_live/age\_name \<=59 ,  
/data/prev\_men\_aged\_15\_and\_59+1, /data/prev\_men\_aged\_15\_and\_59) .This will  
store for the choice value male selected and age range between 15 and 59  
entered.

woman\_aged\_15\_and\_59 = if(/data/Register\_peoples\_live/sex\_name = "female"  
and /data/Register\_peoples\_live/age\_name \>=15 and  
/data/Register\_peoples\_live/age\_name \<=59 ,  
/data/prev\_woman\_aged\_15\_and\_59+1, /data/prev\_woman\_aged\_15\_and\_59) .The  
same which store number of woman

children\_under\_5 = if( /data/Register\_peoples\_live/age\_name \<=  
5,/data/number\_of\_peaples\_staying,' ').For storing children under 5 age  
entered.

Unfortunately this is not working. Could somebody help me how to fix this  
.The way we thought it would work is not working.

Tewelde Aregawi

E-Health Specialist

MVP(MDE)

Tigray/Hawzein

Mobile +251933730215  
Skype : tewelde.aregawi1  
Face Book : tewelde aregawi

Courage, Strength, Determination, Compassion, Loyalty, Selflessness and  
Confidence  
Call  
Send SMS  
Add to Skype  
You'll need Skype CreditFree via Skype

---

<div class="post-metadata">

**Author:** ![William\_Pride](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/w/b19c9b/32.png) [@William\_Pride](https://forum.dimagi.com/u/William_Pride)\
**Post date:** [May 16, 2015, 4:39am UTC](https://forum.dimagi.com/t/we-need-help/2209/2 "2015-05-16T04:39:15Z")

</div>

Hello,

Could you describe what behavior you're seeing when you say its not working?

When debugging calculates like this its often useful to break up the  
constituent parts of the calculate and put them in a label IE:

/data/Register\_peoples\_live/sex\_name = "male"  
/data/Register\_peoples\_live/age\_name \>=15  
/data/Register\_peoples\_live/age\_name \<=59 ,  
/data/prev\_men\_aged\_15\_and\_59

Could all be displayed in a label so that you can identify what parts  
aren't behaving as expected.

Unfortunately I think there might be some other issues with your  
construction - for example, if someone were to swipe backwards to return to  
a previous person, that calculate would fire again and potentially double  
count that person.

One alternative design pattern might be to have some hidden variable that  
takes the value 1 if the person meets the criteria and zero otherwise, IE  
for men:

/data/meets\_criteria = if(/data/Register\_peoples\_live/sex\_name = "male" and  
/data/Register\_peoples\_live/age\_name \>=15 and  
/data/Register\_peoples\_live/age\_name  
\<=59 , 1, 0)

Then, you could call sum  
[https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-sum](https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-sum)  
across  
these nodes and derive your desired value. A similar pattern could be used  
for the child count.

Best,  
Will

> **···**
>
> On Sat, May 16, 2015 at 12:20 AM, Tewelde Aregawi wrote:
> 
> > we are developing Household survey apps.we have created repeat group  
> > that registers all people leaving with in the household head including  
> > their age and sex. From this we need to store all woman with age range 15  
> > and 59,all men with age range 15 and 49 and all children under 5 in hidden  
> > value from the repeat group automatically without asking the household  
> > head again.
> > 
> > To do this we have created hidden values and set the calculate condition  
> > as shown below
> > 
> > prev\_men\_aged\_15\_and\_59 = coalesce(/data/men\_aged\_15\_and\_59, 0)
> > 
> > prev\_woman\_aged\_15\_and\_59 = coalesce(/data/woman\_aged\_15\_and\_59, 0)
> > 
> > men\_aged\_15\_and\_59 = if(/data/Register\_peoples\_live/sex\_name =  
> > "male" and /data/Register\_peoples\_live/age\_name \>=15 and  
> > /data/Register\_peoples\_live/age\_name \<=59 ,  
> > /data/prev\_men\_aged\_15\_and\_59+1, /data/prev\_men\_aged\_15\_and\_59) .This will  
> > store for the choice value male selected and age range between 15 and 59  
> > entered.
> > 
> > woman\_aged\_15\_and\_59 = if(/data/Register\_peoples\_live/sex\_name = "female"  
> > and /data/Register\_peoples\_live/age\_name \>=15 and  
> > /data/Register\_peoples\_live/age\_name \<=59 ,  
> > /data/prev\_woman\_aged\_15\_and\_59+1, /data/prev\_woman\_aged\_15\_and\_59) .The  
> > same which store number of woman
> > 
> > children\_under\_5 = if( /data/Register\_peoples\_live/age\_name \<=  
> > 5,/data/number\_of\_peaples\_staying,' ').For storing children under 5 age  
> > entered.
> > 
> > Unfortunately this is not working. Could somebody help me how to fix this  
> > .The way we thought it would work is not working.
> > 
> > Tewelde Aregawi
> > 
> > E-Health Specialist
> > 
> > MVP(MDE)
> > 
> > Tigray/Hawzein
> > 
> > Mobile +251933730215  
> > Skype : tewelde.aregawi1  
> > Face Book : tewelde aregawi
> > 
> > Courage, Strength, Determination, Compassion, Loyalty, Selflessness and  
> > Confidence  
> > Call  
> > Send SMS  
> > Add to Skype  
> > You'll need Skype CreditFree via Skype
> > 
> > --  
> > 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).

---

<div class="post-metadata">

**Author:** ![Tewelde\_Aregawi](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/t/8c91f0/32.png) [@Tewelde\_Aregawi](https://forum.dimagi.com/u/Tewelde_Aregawi)\
**Post date:** [May 16, 2015, 5:05am UTC](https://forum.dimagi.com/t/we-need-help/2209/3 "2015-05-16T05:05:47Z")

</div>

Dear william

Thanks for the quick response

Actually this was the error i am seeing

Errors making a new version:

- Validation Error: Dependency cycles amongst the xpath expressions in  
relevant/calculate

More information:  
Markup: 1 Unrecognized attributes found in Element [upload] and will be  
ignored: [mediatype]  
Markup: 1 Unrecognized attributes found in Element [upload] and will be  
ignored: [ref]  
Error: XPath Dependency Cycle:  
/data/Register\_peoples\_live/sex\_name =\> /data/men\_aged\_15\_and\_59  
/data/Register\_peoples\_live/sex\_name =\> /data/woman\_aged\_15\_and\_59  
/data/men\_aged\_15\_and\_59 =\> /data/prev\_men\_aged\_15\_and\_59  
/data/prev\_men\_aged\_15\_and\_59 =\> /data/men\_aged\_15\_and\_59  
/data/woman\_aged\_15\_and\_59 =\> /data/prev\_woman\_aged\_15\_and\_59  
/data/Register\_peoples\_live/age\_name =\> /data/men\_aged\_15\_and\_59  
/data/Register\_peoples\_live/age\_name =\> /data/woman\_aged\_15\_and\_59  
/data/prev\_woman\_aged\_15\_and\_59 =\> /data/woman\_aged\_15\_and\_59  
in form

could you please explain more when you say call sum  
[https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-sum](https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-sum)  
across  
these nodes and derive your desired value.It would be best if you can show  
me one example.

Tewelde Aregawi

E-Health Specialist

MVP(MDE)

Tigray/Hawzein

Mobile +251933730215  
Skype : tewelde.aregawi1  
Face Book : tewelde aregawi

Courage, Strength, Determination, Compassion, Loyalty, Selflessness and  
Confidence  
Call  
Send SMS  
Add to Skype  
You'll need Skype CreditFree via Skype

> **···**
>
> On Fri, May 15, 2015 at 9:39 PM, William Pride wrote:
> 
> > Hello,
> > 
> > Could you describe what behavior you're seeing when you say its not  
> > working?
> > 
> > When debugging calculates like this its often useful to break up the  
> > constituent parts of the calculate and put them in a label IE:
> > 
> > /data/Register\_peoples\_live/sex\_name = "male"  
> > /data/Register\_peoples\_live/age\_name \>=15  
> > /data/Register\_peoples\_live/age\_name \<=59 ,  
> > /data/prev\_men\_aged\_15\_and\_59
> > 
> > Could all be displayed in a label so that you can identify what parts  
> > aren't behaving as expected.
> > 
> > Unfortunately I think there might be some other issues with your  
> > construction - for example, if someone were to swipe backwards to return to  
> > a previous person, that calculate would fire again and potentially double  
> > count that person.
> > 
> > One alternative design pattern might be to have some hidden variable that  
> > takes the value 1 if the person meets the criteria and zero otherwise, IE  
> > for men:
> > 
> > /data/meets\_criteria = if(/data/Register\_peoples\_live/sex\_name = "male"  
> > and /data/Register\_peoples\_live/age\_name \>=15 and  
> > /data/Register\_peoples\_live/age\_name \<=59 , 1, 0)
> > 
> > Then, you could call sum  
> > [https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-sum](https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-sum) across  
> > these nodes and derive your desired value. A similar pattern could be used  
> > for the child count.
> > 
> > Best,  
> > Will
> > 
> > On Sat, May 16, 2015 at 12:20 AM, Tewelde Aregawi \<[teweldino.mvp@gmail.com](mailto:teweldino.mvp@gmail.com) wrote:
> > 
> > > we are developing Household survey apps.we have created repeat group  
> > > that registers all people leaving with in the household head including  
> > > their age and sex. From this we need to store all woman with age range 15  
> > > and 59,all men with age range 15 and 49 and all children under 5 in hidden  
> > > value from the repeat group automatically without asking the household  
> > > head again.
> > > 
> > > To do this we have created hidden values and set the calculate  
> > > condition as shown below
> > > 
> > > prev\_men\_aged\_15\_and\_59 = coalesce(/data/men\_aged\_15\_and\_59, 0)
> > > 
> > > prev\_woman\_aged\_15\_and\_59 = coalesce(/data/woman\_aged\_15\_and\_59, 0)
> > > 
> > > men\_aged\_15\_and\_59 = if(/data/Register\_peoples\_live/sex\_name =  
> > > "male" and /data/Register\_peoples\_live/age\_name \>=15 and  
> > > /data/Register\_peoples\_live/age\_name \<=59 ,  
> > > /data/prev\_men\_aged\_15\_and\_59+1, /data/prev\_men\_aged\_15\_and\_59) .This will  
> > > store for the choice value male selected and age range between 15 and 59  
> > > entered.
> > > 
> > > woman\_aged\_15\_and\_59 = if(/data/Register\_peoples\_live/sex\_name = "female"  
> > > and /data/Register\_peoples\_live/age\_name \>=15 and  
> > > /data/Register\_peoples\_live/age\_name \<=59 ,  
> > > /data/prev\_woman\_aged\_15\_and\_59+1, /data/prev\_woman\_aged\_15\_and\_59) .The  
> > > same which store number of woman
> > > 
> > > children\_under\_5 = if( /data/Register\_peoples\_live/age\_name \<=  
> > > 5,/data/number\_of\_peaples\_staying,' ').For storing children under 5 age  
> > > entered.
> > > 
> > > Unfortunately this is not working. Could somebody help me how to fix this  
> > > .The way we thought it would work is not working.
> > > 
> > > Tewelde Aregawi
> > > 
> > > E-Health Specialist
> > > 
> > > MVP(MDE)
> > > 
> > > Tigray/Hawzein
> > > 
> > > Mobile +251933730215  
> > > Skype : tewelde.aregawi1  
> > > Face Book : tewelde aregawi
> > > 
> > > Courage, Strength, Determination, Compassion, Loyalty, Selflessness and  
> > > Confidence  
> > > Call  
> > > Send SMS  
> > > Add to Skype  
> > > You'll need Skype CreditFree via Skype
> > > 
> > > --  
> > > 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).
> > 
> > --  
> > 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).

---

<div class="post-metadata">

**Author:** ![Tewelde\_Aregawi](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/t/8c91f0/32.png) [@Tewelde\_Aregawi](https://forum.dimagi.com/u/Tewelde_Aregawi)\
**Post date:** [May 16, 2015, 8:51am UTC](https://forum.dimagi.com/t/we-need-help/2209/4 "2015-05-16T08:51:40Z")

</div>

Hello

I tried like you suggested me and the result is 0 and 1.The current value  
is overwriting the previous value

prev\_men\_aged\_15\_and\_59 = if(/data/Register\_peoples\_live/sex\_name =  
"male" and /data/Register\_peoples\_live/age\_name \>=15 and  
/data/Register\_peoples\_live/age\_name \<=59 , 1, 0)

men\_aged\_15\_and\_59 = sum(/data/prev\_men\_aged\_15\_and\_59)

Tewelde Aregawi

E-Health Specialist

MVP(MDE)

Tigray/Hawzein

Mobile +251933730215  
Skype : tewelde.aregawi1  
Face Book : tewelde aregawi

Courage, Strength, Determination, Compassion, Loyalty, Selflessness and  
Confidence  
Call  
Send SMS  
Add to Skype  
You'll need Skype CreditFree via Skype

> **···**
>
> On Sat, May 16, 2015 at 9:05 AM, Tewelde Aregawi wrote:
> 
> > Dear william
> > 
> > Thanks for the quick response
> > 
> > Actually this was the error i am seeing
> > 
> > Errors making a new version:
> > 
> > - Validation Error: Dependency cycles amongst the xpath expressions  
> > in relevant/calculate
> > 
> > More information:  
> > Markup: 1 Unrecognized attributes found in Element [upload] and will  
> > be ignored: [mediatype]  
> > Markup: 1 Unrecognized attributes found in Element [upload] and will  
> > be ignored: [ref]  
> > Error: XPath Dependency Cycle:  
> > /data/Register\_peoples\_live/sex\_name =\> /data/men\_aged\_15\_and\_59  
> > /data/Register\_peoples\_live/sex\_name =\> /data/woman\_aged\_15\_and\_59  
> > /data/men\_aged\_15\_and\_59 =\> /data/prev\_men\_aged\_15\_and\_59  
> > /data/prev\_men\_aged\_15\_and\_59 =\> /data/men\_aged\_15\_and\_59  
> > /data/woman\_aged\_15\_and\_59 =\> /data/prev\_woman\_aged\_15\_and\_59  
> > /data/Register\_peoples\_live/age\_name =\> /data/men\_aged\_15\_and\_59  
> > /data/Register\_peoples\_live/age\_name =\> /data/woman\_aged\_15\_and\_59  
> > /data/prev\_woman\_aged\_15\_and\_59 =\> /data/woman\_aged\_15\_and\_59  
> > in form
> > 
> > could you please explain more when you say call sum  
> > [https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-sum](https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-sum) across  
> > these nodes and derive your desired value.It would be best if you can show  
> > me one example.
> > 
> > Tewelde Aregawi
> > 
> > E-Health Specialist
> > 
> > MVP(MDE)
> > 
> > Tigray/Hawzein
> > 
> > Mobile +251933730215  
> > Skype : tewelde.aregawi1  
> > Face Book : tewelde aregawi
> > 
> > Courage, Strength, Determination, Compassion, Loyalty, Selflessness and  
> > Confidence  
> > Call  
> > Send SMS  
> > Add to Skype  
> > You'll need Skype CreditFree via Skype
> > 
> > On Fri, May 15, 2015 at 9:39 PM, William Pride [wpride@dimagi.com](mailto:wpride@dimagi.com) wrote:
> > 
> > > Hello,
> > > 
> > > Could you describe what behavior you're seeing when you say its not  
> > > working?
> > > 
> > > When debugging calculates like this its often useful to break up the  
> > > constituent parts of the calculate and put them in a label IE:
> > > 
> > > /data/Register\_peoples\_live/sex\_name = "male"  
> > > /data/Register\_peoples\_live/age\_name \>=15  
> > > /data/Register\_peoples\_live/age\_name \<=59 ,  
> > > /data/prev\_men\_aged\_15\_and\_59
> > > 
> > > Could all be displayed in a label so that you can identify what parts  
> > > aren't behaving as expected.
> > > 
> > > Unfortunately I think there might be some other issues with your  
> > > construction - for example, if someone were to swipe backwards to return to  
> > > a previous person, that calculate would fire again and potentially double  
> > > count that person.
> > > 
> > > One alternative design pattern might be to have some hidden variable that  
> > > takes the value 1 if the person meets the criteria and zero otherwise, IE  
> > > for men:
> > > 
> > > /data/meets\_criteria = if(/data/Register\_peoples\_live/sex\_name = "male"  
> > > and /data/Register\_peoples\_live/age\_name \>=15 and  
> > > /data/Register\_peoples\_live/age\_name \<=59 , 1, 0)
> > > 
> > > Then, you could call sum  
> > > [https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-sum](https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-sum) across  
> > > these nodes and derive your desired value. A similar pattern could be used  
> > > for the child count.
> > > 
> > > Best,  
> > > Will
> > > 
> > > On Sat, May 16, 2015 at 12:20 AM, Tewelde Aregawi \< [teweldino.mvp@gmail.com](mailto:teweldino.mvp@gmail.com)\> wrote:
> > > 
> > > > we are developing Household survey apps.we have created repeat group  
> > > > that registers all people leaving with in the household head including  
> > > > their age and sex. From this we need to store all woman with age range 15  
> > > > and 59,all men with age range 15 and 49 and all children under 5 in hidden  
> > > > value from the repeat group automatically without asking the household  
> > > > head again.
> > > > 
> > > > To do this we have created hidden values and set the calculate  
> > > > condition as shown below
> > > > 
> > > > prev\_men\_aged\_15\_and\_59 = coalesce(/data/men\_aged\_15\_and\_59, 0)
> > > > 
> > > > prev\_woman\_aged\_15\_and\_59 = coalesce(/data/woman\_aged\_15\_and\_59, 0)
> > > > 
> > > > men\_aged\_15\_and\_59 = if(/data/Register\_peoples\_live/sex\_name =  
> > > > "male" and /data/Register\_peoples\_live/age\_name \>=15 and  
> > > > /data/Register\_peoples\_live/age\_name \<=59 ,  
> > > > /data/prev\_men\_aged\_15\_and\_59+1, /data/prev\_men\_aged\_15\_and\_59) .This will  
> > > > store for the choice value male selected and age range between 15 and 59  
> > > > entered.
> > > > 
> > > > woman\_aged\_15\_and\_59 = if(/data/Register\_peoples\_live/sex\_name =  
> > > > "female" and /data/Register\_peoples\_live/age\_name \>=15 and  
> > > > /data/Register\_peoples\_live/age\_name \<=59 ,  
> > > > /data/prev\_woman\_aged\_15\_and\_59+1, /data/prev\_woman\_aged\_15\_and\_59) .The  
> > > > same which store number of woman
> > > > 
> > > > children\_under\_5 = if( /data/Register\_peoples\_live/age\_name \<=  
> > > > 5,/data/number\_of\_peaples\_staying,' ').For storing children under 5 age  
> > > > entered.
> > > > 
> > > > Unfortunately this is not working. Could somebody help me how to fix  
> > > > this .The way we thought it would work is not working.
> > > > 
> > > > Tewelde Aregawi
> > > > 
> > > > E-Health Specialist
> > > > 
> > > > MVP(MDE)
> > > > 
> > > > Tigray/Hawzein
> > > > 
> > > > Mobile +251933730215  
> > > > Skype : tewelde.aregawi1  
> > > > Face Book : tewelde aregawi
> > > > 
> > > > Courage, Strength, Determination, Compassion, Loyalty, Selflessness and  
> > > > Confidence  
> > > > Call  
> > > > Send SMS  
> > > > Add to Skype  
> > > > You'll need Skype CreditFree via Skype
> > > > 
> > > > --  
> > > > 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).
> > > 
> > > --  
> > > 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).

---

<div class="post-metadata">

**Author:** ![William\_Pride](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/w/b19c9b/32.png) [@William\_Pride](https://forum.dimagi.com/u/William_Pride)\
**Post date:** [May 16, 2015, 3:05pm UTC](https://forum.dimagi.com/t/we-need-help/2209/5 "2015-05-16T15:05:17Z")

</div>

Hello,

You'll need to that value within the repeated node set so that it gets set  
for every person. Then, you calculate the sum _outside_ the repeat group  
after you've gone through every person. Please note that you'll no longer  
to calculate anything like the "previous" count in this design - you'll  
just set this value to 1 or 0 for each repeat iteration, then sum  
everything at the end.

Best,  
Will

> **···**
>
> On Sat, May 16, 2015 at 4:51 AM, Tewelde Aregawi wrote:
> 
> > Hello
> > 
> > I tried like you suggested me and the result is 0 and 1.The current value  
> > is overwriting the previous value
> > 
> > prev\_men\_aged\_15\_and\_59 = if(/data/Register\_peoples\_live/sex\_name =  
> > "male" and /data/Register\_peoples\_live/age\_name \>=15 and  
> > /data/Register\_peoples\_live/age\_name \<=59 , 1, 0)
> > 
> > men\_aged\_15\_and\_59 = sum(/data/prev\_men\_aged\_15\_and\_59)
> > 
> > Tewelde Aregawi
> > 
> > E-Health Specialist
> > 
> > MVP(MDE)
> > 
> > Tigray/Hawzein
> > 
> > Mobile +251933730215  
> > Skype : tewelde.aregawi1  
> > Face Book : tewelde aregawi
> > 
> > Courage, Strength, Determination, Compassion, Loyalty, Selflessness and  
> > Confidence  
> > Call  
> > Send SMS  
> > Add to Skype  
> > You'll need Skype CreditFree via Skype
> > 
> > On Sat, May 16, 2015 at 9:05 AM, Tewelde Aregawi [teweldino.mvp@gmail.com](mailto:teweldino.mvp@gmail.com) wrote:
> > 
> > > Dear william
> > > 
> > > Thanks for the quick response
> > > 
> > > Actually this was the error i am seeing
> > > 
> > > Errors making a new version:
> > > 
> > > - Validation Error: Dependency cycles amongst the xpath expressions  
> > > in relevant/calculate
> > > 
> > > More information:  
> > > Markup: 1 Unrecognized attributes found in Element [upload] and will  
> > > be ignored: [mediatype]  
> > > Markup: 1 Unrecognized attributes found in Element [upload] and will  
> > > be ignored: [ref]  
> > > Error: XPath Dependency Cycle:  
> > > /data/Register\_peoples\_live/sex\_name =\> /data/men\_aged\_15\_and\_59  
> > > /data/Register\_peoples\_live/sex\_name =\> /data/woman\_aged\_15\_and\_59  
> > > /data/men\_aged\_15\_and\_59 =\> /data/prev\_men\_aged\_15\_and\_59  
> > > /data/prev\_men\_aged\_15\_and\_59 =\> /data/men\_aged\_15\_and\_59  
> > > /data/woman\_aged\_15\_and\_59 =\> /data/prev\_woman\_aged\_15\_and\_59  
> > > /data/Register\_peoples\_live/age\_name =\> /data/men\_aged\_15\_and\_59  
> > > /data/Register\_peoples\_live/age\_name =\> /data/woman\_aged\_15\_and\_59  
> > > /data/prev\_woman\_aged\_15\_and\_59 =\> /data/woman\_aged\_15\_and\_59  
> > > in form
> > > 
> > > could you please explain more when you say call sum  
> > > [https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-sum](https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-sum) across  
> > > these nodes and derive your desired value.It would be best if you can show  
> > > me one example.
> > > 
> > > Tewelde Aregawi
> > > 
> > > E-Health Specialist
> > > 
> > > MVP(MDE)
> > > 
> > > Tigray/Hawzein
> > > 
> > > Mobile +251933730215  
> > > Skype : tewelde.aregawi1  
> > > Face Book : tewelde aregawi
> > > 
> > > Courage, Strength, Determination, Compassion, Loyalty, Selflessness and  
> > > Confidence  
> > > Call  
> > > Send SMS  
> > > Add to Skype  
> > > You'll need Skype CreditFree via Skype
> > > 
> > > On Fri, May 15, 2015 at 9:39 PM, William Pride [wpride@dimagi.com](mailto:wpride@dimagi.com) wrote:
> > > 
> > > > Hello,
> > > > 
> > > > Could you describe what behavior you're seeing when you say its not  
> > > > working?
> > > > 
> > > > When debugging calculates like this its often useful to break up the  
> > > > constituent parts of the calculate and put them in a label IE:
> > > > 
> > > > /data/Register\_peoples\_live/sex\_name = "male"  
> > > > /data/Register\_peoples\_live/age\_name \>=15  
> > > > /data/Register\_peoples\_live/age\_name \<=59 ,  
> > > > /data/prev\_men\_aged\_15\_and\_59
> > > > 
> > > > Could all be displayed in a label so that you can identify what parts  
> > > > aren't behaving as expected.
> > > > 
> > > > Unfortunately I think there might be some other issues with your  
> > > > construction - for example, if someone were to swipe backwards to return to  
> > > > a previous person, that calculate would fire again and potentially double  
> > > > count that person.
> > > > 
> > > > One alternative design pattern might be to have some hidden variable  
> > > > that takes the value 1 if the person meets the criteria and zero otherwise,  
> > > > IE for men:
> > > > 
> > > > /data/meets\_criteria = if(/data/Register\_peoples\_live/sex\_name = "male"  
> > > > and /data/Register\_peoples\_live/age\_name \>=15 and  
> > > > /data/Register\_peoples\_live/age\_name \<=59 , 1, 0)
> > > > 
> > > > Then, you could call sum  
> > > > [https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-sum](https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-sum) across  
> > > > these nodes and derive your desired value. A similar pattern could be used  
> > > > for the child count.
> > > > 
> > > > Best,  
> > > > Will
> > > > 
> > > > On Sat, May 16, 2015 at 12:20 AM, Tewelde Aregawi \< [teweldino.mvp@gmail.com](mailto:teweldino.mvp@gmail.com)\> wrote:
> > > > 
> > > > > we are developing Household survey apps.we have created repeat group  
> > > > > that registers all people leaving with in the household head including  
> > > > > their age and sex. From this we need to store all woman with age range 15  
> > > > > and 59,all men with age range 15 and 49 and all children under 5 in hidden  
> > > > > value from the repeat group automatically without asking the household  
> > > > > head again.
> > > > > 
> > > > > To do this we have created hidden values and set the calculate  
> > > > > condition as shown below
> > > > > 
> > > > > prev\_men\_aged\_15\_and\_59 = coalesce(/data/men\_aged\_15\_and\_59, 0)
> > > > > 
> > > > > prev\_woman\_aged\_15\_and\_59 = coalesce(/data/woman\_aged\_15\_and\_59, 0)
> > > > > 
> > > > > men\_aged\_15\_and\_59 = if(/data/Register\_peoples\_live/sex\_name =  
> > > > > "male" and /data/Register\_peoples\_live/age\_name \>=15 and  
> > > > > /data/Register\_peoples\_live/age\_name \<=59 ,  
> > > > > /data/prev\_men\_aged\_15\_and\_59+1, /data/prev\_men\_aged\_15\_and\_59) .This will  
> > > > > store for the choice value male selected and age range between 15 and 59  
> > > > > entered.
> > > > > 
> > > > > woman\_aged\_15\_and\_59 = if(/data/Register\_peoples\_live/sex\_name =  
> > > > > "female" and /data/Register\_peoples\_live/age\_name \>=15 and  
> > > > > /data/Register\_peoples\_live/age\_name \<=59 ,  
> > > > > /data/prev\_woman\_aged\_15\_and\_59+1, /data/prev\_woman\_aged\_15\_and\_59) .The  
> > > > > same which store number of woman
> > > > > 
> > > > > children\_under\_5 = if( /data/Register\_peoples\_live/age\_name \<=  
> > > > > 5,/data/number\_of\_peaples\_staying,' ').For storing children under 5 age  
> > > > > entered.
> > > > > 
> > > > > Unfortunately this is not working. Could somebody help me how to fix  
> > > > > this .The way we thought it would work is not working.
> > > > > 
> > > > > Tewelde Aregawi
> > > > > 
> > > > > E-Health Specialist
> > > > > 
> > > > > MVP(MDE)
> > > > > 
> > > > > Tigray/Hawzein
> > > > > 
> > > > > Mobile +251933730215  
> > > > > Skype : tewelde.aregawi1  
> > > > > Face Book : tewelde aregawi
> > > > > 
> > > > > Courage, Strength, Determination, Compassion, Loyalty, Selflessness and  
> > > > > Confidence  
> > > > > Call  
> > > > > Send SMS  
> > > > > Add to Skype  
> > > > > You'll need Skype CreditFree via Skype
> > > > > 
> > > > > --  
> > > > > 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).
> > > > 
> > > > --  
> > > > 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).
> > 
> > --  
> > 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).
