Filtering and counting by answer within a repeat group

Hi all,

I have a repeat group that collects information about children (birthdate,
age at last birthday, date of death, age before dying etc.) I have
questions later in the survey that are based off of the answers within this
repeat group. Following this link:
https://help.commcarehq.org/display/commcarepublic/Using+Repeat+Groups+in+the+Form+Builder
I have tried to use what is recommended, but I am still getting errors. I
actually do not use the (…) when writing logic between questions within
the repeat group (because I kept getting errors), and it still worked. I’m
currently trying to count outside of the repeat group, but it still is not
working. Please advise. I have lists within the repeat group as well, but
I’m not sure if that is what is causing the error.

Here are the specific cases that haven’t worked so far…

  1. counting alive children under 5
    count(#form/hsld_section/children_information [#form/hsld_section/children_information/children_informationlist/ChildLiving
    = ‘yes’] [#form/hsld_section/children_information/children_informationlist/ChildAge/calc_aliveyears
    < 5])

  2. storing the name of the youngest child under 5 [not sure if this is
    possible]

  3. counting alive children ages 13-18

  4. counting alive children ages 13-18 that are females

  5. counting alive children ages 13-18 that are males

  6. counting number of alive children 18 and under

If this is not the best way to do this, is there another way using if
statements with true/false or something else? When I have tried if(___,
true(), false()) without using any type of special code for repeat groups,
I do not get an error when saving the calculation, however, I have not
tested this to see if it breaks when the group is repeated several times.

FYI if a child is alive, I calculate their age in days, months, and years.
Depending upon these numbers a question is displayed to confirm their age (RECORD
in days if less than 1 month, months if less than two years, or years
).

Cheers

Hi Staci,

Your first statement was actually quite close but off on a minor detail. I
believe the expression:

count(#form/hsld_section/children_information [ChildLiving = ‘yes’] [
ChildAge/calc_aliveyears < 5])

Would work correctly. To explain, you can think of the count() expression
as iterating over each node in the repeat. So, when you type [ChildLiving =
‘yes’] you are referencing the current iteration. However when you
write [#form/hsld_section/children_information/children_informationlist/ChildLiving
= ‘yes’] you are losing this iterative context and referencing the absolute
path - which is not well defined
since "#form/hsld_section/children_information/children_informationlist/ChildLiving"
can point to multiple nodes given that children_information is repeated.

The same pattern should work for your other counts.

As to (2) I believe you could use the minimum
https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-min
function
to determine the lowest age, then use a filter expression similar to above
to find the name of the child with this age.

Cheers,
Will

··· On Thu, Dec 15, 2016 at 2:24 AM, Staci Leigh wrote:

Hi all,

I have a repeat group that collects information about children (birthdate,
age at last birthday, date of death, age before dying etc.) I have
questions later in the survey that are based off of the answers within this
repeat group. Following this link: https://help.commcarehq.
org/display/commcarepublic/Using+Repeat+Groups+in+the+Form+Builder
I have tried to use what is recommended, but I am still getting errors. I
actually do not use the (…) when writing logic between questions within
the repeat group (because I kept getting errors), and it still worked. I’m
currently trying to count outside of the repeat group, but it still is not
working. Please advise. I have lists within the repeat group as well, but
I’m not sure if that is what is causing the error.

Here are the specific cases that haven’t worked so far…

  1. counting alive children under 5
    count(#form/hsld_section/children_information [
    #form/hsld_section/children_information/children_informationlist/ChildLiving
    = ‘yes’] [#form/hsld_section/children_information/children_
    informationlist/ChildAge/calc_aliveyears < 5])

  2. storing the name of the youngest child under 5 [not sure if this is
    possible]

  3. counting alive children ages 13-18

  4. counting alive children ages 13-18 that are females

  5. counting alive children ages 13-18 that are males

  6. counting number of alive children 18 and under

If this is not the best way to do this, is there another way using if
statements with true/false or something else? When I have tried if(___,
true(), false()) without using any type of special code for repeat groups,
I do not get an error when saving the calculation, however, I have not
tested this to see if it breaks when the group is repeated several times.

FYI if a child is alive, I calculate their age in days, months, and years.
Depending upon these numbers a question is displayed to confirm their age (RECORD
in days if less than 1 month, months if less than two years, or years
).

Cheers


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.

Hi Will,

Thank you for your response. Your explanation is clear.

When I try:
count(#form/hsld_section/children_information [ChildLiving = ‘yes’] [ChildAge/calc_aliveyears
< 5])

I get an error message:

https://lh3.googleusercontent.com/-JtOKVGdSWJY/WFOwZeews-I/AAAAAAAAAkg/x1787uYSMUYtRi7BwrJ597EXVerZ1PeWgCLcB/s1600/errormessage.png

If I drag and drop the repeat group into the calculate condition field, I
get this error message (though there is no dash before #form…):

https://lh3.googleusercontent.com/-F-wgwdm3xjs/WFOxCOEeu6I/AAAAAAAAAko/Lj1o_nACSNU3NFEwk6qwhJeyPXiUSiXEQCLcB/s1600/errormessage2.png

Within the repeat group “children_information”, I have a question list
("children_informationlist ") so that all repeat questions display on one
page. “ChildLiving” is within this list. I have an additional list (within
the larger list of questions), “ChildAge” and within this, I have the
hidden value “calc_aliveyears”. Even if I try :
count(#form/hsld_section/children_information
[children_informationlist/ChildLiving = ‘yes’]
[children_informationlist/ChildAge/calc_aliveyears < 5]) I still get the
same parse error.

Am I missing something small?

Cheers,

Staci

··· On Thursday, December 15, 2016 at 10:24:59 AM UTC+3, Staci Leigh wrote: > > Hi all, > > I have a repeat group that collects information about children (birthdate, > age at last birthday, date of death, age before dying etc.) I have > questions later in the survey that are based off of the answers within this > repeat group. Following this link: > https://help.commcarehq.org/display/commcarepublic/Using+Repeat+Groups+in+the+Form+Builder > I have tried to use what is recommended, but I am still getting errors. I > actually do not use the (..) when writing logic between questions within > the repeat group (because I kept getting errors), and it still worked. I'm > currently trying to count outside of the repeat group, but it still is not > working. Please advise. I have lists within the repeat group as well, but > I'm not sure if that is what is causing the error. > > Here are the specific cases that haven't worked so far.. > > 1) counting alive children under 5 > count(#form/hsld_section/children_information [#form/hsld_section/children_information/children_informationlist/ChildLiving > = 'yes'] [#form/hsld_section/children_information/children_informationlist/ChildAge/calc_aliveyears > < 5]) > > 2) storing the name of the youngest child under 5 [not sure if this is > possible] > 3) counting alive children ages 13-18 > 4) counting alive children ages 13-18 that are females > 5) counting alive children ages 13-18 that are males > 6) counting number of alive children 18 and under > > If this is not the best way to do this, is there another way using if > statements with true/false or something else? When I have tried if(___, > true(), false()) without using any type of special code for repeat groups, > I do not get an error when saving the calculation, however, I have not > tested this to see if it breaks when the group is repeated several times. > > FYI if a child is alive, I calculate their age in days, months, and years. > Depending upon these numbers a question is displayed to confirm their age (*RECORD > in days if less than 1 month, months if less than two years, or years*). > > Cheers > >

Staci,

Strange, that path looks valid and I haven’t seen those error messages
before. Could you file a bug report
https://confluence.dimagi.com/display/commcarepublic/Bug+Reports so that
we can take a look at your form?

Cheers,
Will

··· On Fri, Dec 16, 2016 at 5:21 AM, Staci Leigh wrote:

Hi Will,

Thank you for your response. Your explanation is clear.

When I try:
count(#form/hsld_section/children_information [ChildLiving = ‘yes’] [ChildAge/calc_aliveyears
< 5])

I get an error message:

https://lh3.googleusercontent.com/-JtOKVGdSWJY/WFOwZeews-I/AAAAAAAAAkg/x1787uYSMUYtRi7BwrJ597EXVerZ1PeWgCLcB/s1600/errormessage.png

If I drag and drop the repeat group into the calculate condition field, I
get this error message (though there is no dash before #form…):

https://lh3.googleusercontent.com/-F-wgwdm3xjs/WFOxCOEeu6I/AAAAAAAAAko/Lj1o_nACSNU3NFEwk6qwhJeyPXiUSiXEQCLcB/s1600/errormessage2.png

Within the repeat group “children_information”, I have a question list
("children_informationlist ") so that all repeat questions display on one
page. “ChildLiving” is within this list. I have an additional list (within
the larger list of questions), “ChildAge” and within this, I have the
hidden value “calc_aliveyears”. Even if I try : count(#form/hsld_section/children_information
[children_informationlist/ChildLiving = ‘yes’] [children_informationlist/ChildAge/calc_aliveyears
< 5]) I still get the same parse error.

Am I missing something small?

Cheers,

Staci

On Thursday, December 15, 2016 at 10:24:59 AM UTC+3, Staci Leigh wrote:

Hi all,

I have a repeat group that collects information about children
(birthdate, age at last birthday, date of death, age before dying etc.) I
have questions later in the survey that are based off of the answers within
this repeat group. Following this link: https://help.commcarehq.
org/display/commcarepublic/Using+Repeat+Groups+in+the+Form+Builder
I have tried to use what is recommended, but I am still getting errors. I
actually do not use the (…) when writing logic between questions within
the repeat group (because I kept getting errors), and it still worked. I’m
currently trying to count outside of the repeat group, but it still is not
working. Please advise. I have lists within the repeat group as well, but
I’m not sure if that is what is causing the error.

Here are the specific cases that haven’t worked so far…

  1. counting alive children under 5
    count(#form/hsld_section/children_information [
    #form/hsld_section/children_information/children_informationlist/ChildLiving
    = ‘yes’] [#form/hsld_section/children_information/children_informationlist/ChildAge/calc_aliveyears
    < 5])

  2. storing the name of the youngest child under 5 [not sure if this is
    possible]

  3. counting alive children ages 13-18

  4. counting alive children ages 13-18 that are females

  5. counting alive children ages 13-18 that are males

  6. counting number of alive children 18 and under

If this is not the best way to do this, is there another way using if
statements with true/false or something else? When I have tried if(___,
true(), false()) without using any type of special code for repeat groups,
I do not get an error when saving the calculation, however, I have not
tested this to see if it breaks when the group is repeated several times.

FYI if a child is alive, I calculate their age in days, months, and
years. Depending upon these numbers a question is displayed to confirm
their age (RECORD in days if less than 1 month, months if less than two
years, or years
).

Cheers


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.

Hi Will,

Thank you for your reply and your help! If anyone runs into this issue in
the future, it is helpful to delete the hidden value and start from
scratch. This deletes the accidental unremovable ’ from being placed into
the calculate condition.

Cheers,

Staci

··· On Friday, December 16, 2016 at 3:54:44 PM UTC+3, William Pride wrote: > > Staci, > > Strange, that path looks valid and I haven't seen those error messages > before. Could you file a bug report > so > that we can take a look at your form? > > Cheers, > Will > > On Fri, Dec 16, 2016 at 5:21 AM, Staci Leigh <staci.su...@gmail.com > wrote: > >> Hi Will, >> >> Thank you for your response. Your explanation is clear. >> >> When I try: >> count(#form/hsld_section/children_information [ChildLiving = 'yes'] [ChildAge/calc_aliveyears >> < 5]) >> >> I get an error message: >> >> >> >> >> >> If I drag and drop the repeat group into the calculate condition field, I >> get this error message (though there is no dash before #form...): >> >> >> >> >> >> Within the repeat group "children_information", I have a question list >> ("children_informationlist ") so that all repeat questions display on one >> page. "ChildLiving" is within this list. I have an additional list (within >> the larger list of questions), "ChildAge" and within this, I have the >> hidden value "calc_aliveyears". Even if I try : >> count(#form/hsld_section/children_information >> [children_informationlist/ChildLiving = 'yes'] >> [children_informationlist/ChildAge/calc_aliveyears < 5]) I still get the >> same parse error. >> >> >> Am I missing something small? >> >> >> Cheers, >> >> >> Staci >> >> >> >> >> On Thursday, December 15, 2016 at 10:24:59 AM UTC+3, Staci Leigh wrote: >>> >>> Hi all, >>> >>> I have a repeat group that collects information about children >>> (birthdate, age at last birthday, date of death, age before dying etc.) I >>> have questions later in the survey that are based off of the answers within >>> this repeat group. Following this link: >>> https://help.commcarehq.org/display/commcarepublic/Using+Repeat+Groups+in+the+Form+Builder >>> I have tried to use what is recommended, but I am still getting errors. >>> I actually do not use the (..) when writing logic between questions within >>> the repeat group (because I kept getting errors), and it still worked. I'm >>> currently trying to count outside of the repeat group, but it still is not >>> working. Please advise. I have lists within the repeat group as well, but >>> I'm not sure if that is what is causing the error. >>> >>> Here are the specific cases that haven't worked so far.. >>> >>> 1) counting alive children under 5 >>> count(#form/hsld_section/children_information [#form/hsld_section/children_information/children_informationlist/ChildLiving >>> = 'yes'] [#form/hsld_section/children_information/children_informationlist/ChildAge/calc_aliveyears >>> < 5]) >>> >>> 2) storing the name of the youngest child under 5 [not sure if this is >>> possible] >>> 3) counting alive children ages 13-18 >>> 4) counting alive children ages 13-18 that are females >>> 5) counting alive children ages 13-18 that are males >>> 6) counting number of alive children 18 and under >>> >>> If this is not the best way to do this, is there another way using if >>> statements with true/false or something else? When I have tried if(___, >>> true(), false()) without using any type of special code for repeat groups, >>> I do not get an error when saving the calculation, however, I have not >>> tested this to see if it breaks when the group is repeated several times. >>> >>> FYI if a child is alive, I calculate their age in days, months, and >>> years. Depending upon these numbers a question is displayed to confirm >>> their age (*RECORD in days if less than 1 month, months if less than >>> two years, or years*). >>> >>> Cheers >>> >>> -- >> 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-user...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > >

Hi staci and Will

I am getting this same error, how did you resolve the issue?

Cheers,
Jess

··· On Tuesday, December 20, 2016 at 1:44:50 AM UTC+11, Staci Leigh wrote: > > Hi Will, > > Thank you for your reply and your help! If anyone runs into this issue in > the future, it is helpful to delete the hidden value and start from > scratch. This deletes the accidental unremovable ' from being placed into > the calculate condition. > > Cheers, > > Staci > > On Friday, December 16, 2016 at 3:54:44 PM UTC+3, William Pride wrote: >> >> Staci, >> >> Strange, that path looks valid and I haven't seen those error messages >> before. Could you file a bug report >> so >> that we can take a look at your form? >> >> Cheers, >> Will >> >> On Fri, Dec 16, 2016 at 5:21 AM, Staci Leigh wrote: >> >>> Hi Will, >>> >>> Thank you for your response. Your explanation is clear. >>> >>> When I try: >>> count(#form/hsld_section/children_information [ChildLiving = 'yes'] [ChildAge/calc_aliveyears >>> < 5]) >>> >>> I get an error message: >>> >>> >>> >>> >>> >>> If I drag and drop the repeat group into the calculate condition field, >>> I get this error message (though there is no dash before #form...): >>> >>> >>> >>> >>> >>> Within the repeat group "children_information", I have a question list >>> ("children_informationlist ") so that all repeat questions display on one >>> page. "ChildLiving" is within this list. I have an additional list (within >>> the larger list of questions), "ChildAge" and within this, I have the >>> hidden value "calc_aliveyears". Even if I try : >>> count(#form/hsld_section/children_information >>> [children_informationlist/ChildLiving = 'yes'] >>> [children_informationlist/ChildAge/calc_aliveyears < 5]) I still get the >>> same parse error. >>> >>> >>> Am I missing something small? >>> >>> >>> Cheers, >>> >>> >>> Staci >>> >>> >>> >>> >>> On Thursday, December 15, 2016 at 10:24:59 AM UTC+3, Staci Leigh wrote: >>>> >>>> Hi all, >>>> >>>> I have a repeat group that collects information about children >>>> (birthdate, age at last birthday, date of death, age before dying etc.) I >>>> have questions later in the survey that are based off of the answers within >>>> this repeat group. Following this link: >>>> https://help.commcarehq.org/display/commcarepublic/Using+Repeat+Groups+in+the+Form+Builder >>>> I have tried to use what is recommended, but I am still getting errors. >>>> I actually do not use the (..) when writing logic between questions within >>>> the repeat group (because I kept getting errors), and it still worked. I'm >>>> currently trying to count outside of the repeat group, but it still is not >>>> working. Please advise. I have lists within the repeat group as well, but >>>> I'm not sure if that is what is causing the error. >>>> >>>> Here are the specific cases that haven't worked so far.. >>>> >>>> 1) counting alive children under 5 >>>> count(#form/hsld_section/children_information [#form/hsld_section/children_information/children_informationlist/ChildLiving >>>> = 'yes'] [#form/hsld_section/children_information/children_informationlist/ChildAge/calc_aliveyears >>>> < 5]) >>>> >>>> 2) storing the name of the youngest child under 5 [not sure if this is >>>> possible] >>>> 3) counting alive children ages 13-18 >>>> 4) counting alive children ages 13-18 that are females >>>> 5) counting alive children ages 13-18 that are males >>>> 6) counting number of alive children 18 and under >>>> >>>> If this is not the best way to do this, is there another way using if >>>> statements with true/false or something else? When I have tried if(___, >>>> true(), false()) without using any type of special code for repeat groups, >>>> I do not get an error when saving the calculation, however, I have not >>>> tested this to see if it breaks when the group is repeated several times. >>>> >>>> FYI if a child is alive, I calculate their age in days, months, and >>>> years. Depending upon these numbers a question is displayed to confirm >>>> their age (*RECORD in days if less than 1 month, months if less than >>>> two years, or years*). >>>> >>>> Cheers >>>> >>>> -- >>> 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-user...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >>

Jess,

The issue here was that easy references currently doesn’t support the
filter expressions (IE the ‘[ ]’ portion) in repeat groups. The workaround
I recommended was that instead of using the easy references '#form/…'
style path you use the old ‘/data/…’ format instead.

Cheers,
Will

··· On Wed, Dec 21, 2016 at 2:52 AM, wrote:

Hi staci and Will

I am getting this same error, how did you resolve the issue?

Cheers,
Jess

On Tuesday, December 20, 2016 at 1:44:50 AM UTC+11, Staci Leigh wrote:

Hi Will,

Thank you for your reply and your help! If anyone runs into this issue in
the future, it is helpful to delete the hidden value and start from
scratch. This deletes the accidental unremovable ’ from being placed into
the calculate condition.

Cheers,

Staci

On Friday, December 16, 2016 at 3:54:44 PM UTC+3, William Pride wrote:

Staci,

Strange, that path looks valid and I haven’t seen those error messages
before. Could you file a bug report
https://confluence.dimagi.com/display/commcarepublic/Bug+Reports so
that we can take a look at your form?

Cheers,
Will

On Fri, Dec 16, 2016 at 5:21 AM, Staci Leigh staci.su...@gmail.com wrote:

Hi Will,

Thank you for your response. Your explanation is clear.

When I try:
count(#form/hsld_section/children_information [ChildLiving = ‘yes’] [ChildAge/calc_aliveyears
< 5])

I get an error message:

https://lh3.googleusercontent.com/-JtOKVGdSWJY/WFOwZeews-I/AAAAAAAAAkg/x1787uYSMUYtRi7BwrJ597EXVerZ1PeWgCLcB/s1600/errormessage.png

If I drag and drop the repeat group into the calculate condition field,
I get this error message (though there is no dash before #form…):

https://lh3.googleusercontent.com/-F-wgwdm3xjs/WFOxCOEeu6I/AAAAAAAAAko/Lj1o_nACSNU3NFEwk6qwhJeyPXiUSiXEQCLcB/s1600/errormessage2.png

Within the repeat group “children_information”, I have a question list
("children_informationlist ") so that all repeat questions display on one
page. “ChildLiving” is within this list. I have an additional list (within
the larger list of questions), “ChildAge” and within this, I have the
hidden value “calc_aliveyears”. Even if I try :
count(#form/hsld_section/children_information
[children_informationlist/ChildLiving = ‘yes’]
[children_informationlist/ChildAge/calc_aliveyears < 5]) I still get
the same parse error.

Am I missing something small?

Cheers,

Staci

On Thursday, December 15, 2016 at 10:24:59 AM UTC+3, Staci Leigh wrote:

Hi all,

I have a repeat group that collects information about children
(birthdate, age at last birthday, date of death, age before dying etc.) I
have questions later in the survey that are based off of the answers within
this repeat group. Following this link: https://help.commcarehq.
org/display/commcarepublic/Using+Repeat+Groups+in+the+Form+Builder
I have tried to use what is recommended, but I am still getting
errors. I actually do not use the (…) when writing logic between questions
within the repeat group (because I kept getting errors), and it still
worked. I’m currently trying to count outside of the repeat group, but it
still is not working. Please advise. I have lists within the repeat group
as well, but I’m not sure if that is what is causing the error.

Here are the specific cases that haven’t worked so far…

  1. counting alive children under 5
    count(#form/hsld_section/children_information [
    #form/hsld_section/children_information/children_informationlist/ChildLiving
    = ‘yes’] [#form/hsld_section/children_information/children_informationlist/ChildAge/calc_aliveyears
    < 5])

  2. storing the name of the youngest child under 5 [not sure if this is
    possible]

  3. counting alive children ages 13-18

  4. counting alive children ages 13-18 that are females

  5. counting alive children ages 13-18 that are males

  6. counting number of alive children 18 and under

If this is not the best way to do this, is there another way using if
statements with true/false or something else? When I have tried if(___,
true(), false()) without using any type of special code for repeat groups,
I do not get an error when saving the calculation, however, I have not
tested this to see if it breaks when the group is repeated several times.

FYI if a child is alive, I calculate their age in days, months, and
years. Depending upon these numbers a question is displayed to confirm
their age (RECORD in days if less than 1 month, months if less than
two years, or years
).

Cheers


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-user...@googlegroups.com.
For more options, visit 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.
For more options, visit https://groups.google.com/d/optout.

ok thanks Will

··· On Thursday, December 22, 2016 at 2:22:53 AM UTC+11, William Pride wrote: > > Jess, > > The issue here was that easy references currently doesn't support the > filter expressions (IE the '[ ]' portion) in repeat groups. The workaround > I recommended was that instead of using the easy references '#form/...' > style path you use the old '/data/...' format instead. > > Cheers, > Will > > On Wed, Dec 21, 2016 at 2:52 AM, <jes...@agimpact.org > wrote: > >> Hi staci and Will >> >> I am getting this same error, how did you resolve the issue? >> >> Cheers, >> Jess >> >> >> On Tuesday, December 20, 2016 at 1:44:50 AM UTC+11, Staci Leigh wrote: >>> >>> Hi Will, >>> >>> Thank you for your reply and your help! If anyone runs into this issue >>> in the future, it is helpful to delete the hidden value and start from >>> scratch. This deletes the accidental unremovable ' from being placed into >>> the calculate condition. >>> >>> Cheers, >>> >>> Staci >>> >>> On Friday, December 16, 2016 at 3:54:44 PM UTC+3, William Pride wrote: >>>> >>>> Staci, >>>> >>>> Strange, that path looks valid and I haven't seen those error messages >>>> before. Could you file a bug report >>>> so >>>> that we can take a look at your form? >>>> >>>> Cheers, >>>> Will >>>> >>>> On Fri, Dec 16, 2016 at 5:21 AM, Staci Leigh wrote: >>>> >>>>> Hi Will, >>>>> >>>>> Thank you for your response. Your explanation is clear. >>>>> >>>>> When I try: >>>>> count(#form/hsld_section/children_information [ChildLiving = 'yes'] [ChildAge/calc_aliveyears >>>>> < 5]) >>>>> >>>>> I get an error message: >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> If I drag and drop the repeat group into the calculate condition >>>>> field, I get this error message (though there is no dash before #form...): >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> Within the repeat group "children_information", I have a question list >>>>> ("children_informationlist ") so that all repeat questions display on one >>>>> page. "ChildLiving" is within this list. I have an additional list (within >>>>> the larger list of questions), "ChildAge" and within this, I have the >>>>> hidden value "calc_aliveyears". Even if I try : >>>>> count(#form/hsld_section/children_information >>>>> [children_informationlist/ChildLiving = 'yes'] >>>>> [children_informationlist/ChildAge/calc_aliveyears < 5]) I still get the >>>>> same parse error. >>>>> >>>>> >>>>> Am I missing something small? >>>>> >>>>> >>>>> Cheers, >>>>> >>>>> >>>>> Staci >>>>> >>>>> >>>>> >>>>> >>>>> On Thursday, December 15, 2016 at 10:24:59 AM UTC+3, Staci Leigh wrote: >>>>>> >>>>>> Hi all, >>>>>> >>>>>> I have a repeat group that collects information about children >>>>>> (birthdate, age at last birthday, date of death, age before dying etc.) I >>>>>> have questions later in the survey that are based off of the answers within >>>>>> this repeat group. Following this link: >>>>>> https://help.commcarehq.org/display/commcarepublic/Using+Repeat+Groups+in+the+Form+Builder >>>>>> I have tried to use what is recommended, but I am still getting >>>>>> errors. I actually do not use the (..) when writing logic between questions >>>>>> within the repeat group (because I kept getting errors), and it still >>>>>> worked. I'm currently trying to count outside of the repeat group, but it >>>>>> still is not working. Please advise. I have lists within the repeat group >>>>>> as well, but I'm not sure if that is what is causing the error. >>>>>> >>>>>> Here are the specific cases that haven't worked so far.. >>>>>> >>>>>> 1) counting alive children under 5 >>>>>> count(#form/hsld_section/children_information [#form/hsld_section/children_information/children_informationlist/ChildLiving >>>>>> = 'yes'] [#form/hsld_section/children_information/children_informationlist/ChildAge/calc_aliveyears >>>>>> < 5]) >>>>>> >>>>>> 2) storing the name of the youngest child under 5 [not sure if this >>>>>> is possible] >>>>>> 3) counting alive children ages 13-18 >>>>>> 4) counting alive children ages 13-18 that are females >>>>>> 5) counting alive children ages 13-18 that are males >>>>>> 6) counting number of alive children 18 and under >>>>>> >>>>>> If this is not the best way to do this, is there another way using if >>>>>> statements with true/false or something else? When I have tried if(___, >>>>>> true(), false()) without using any type of special code for repeat groups, >>>>>> I do not get an error when saving the calculation, however, I have not >>>>>> tested this to see if it breaks when the group is repeated several times. >>>>>> >>>>>> FYI if a child is alive, I calculate their age in days, months, and >>>>>> years. Depending upon these numbers a question is displayed to confirm >>>>>> their age (*RECORD in days if less than 1 month, months if less than >>>>>> two years, or years*). >>>>>> >>>>>> Cheers >>>>>> >>>>>> -- >>>>> 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-user...@googlegroups.com. >>>>> For more options, visit 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-user...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > >