Count using several conditions based on Roster (part 2)

A similar to previous post (sorry for double posting, previous was left as a comment)

I need to enable section if a number of alive children from the roster for one woman is either above 0 or equal 0. However, it doesn’t accept the expressions.

The warning is - Operator > cannot be applied to operands of type bool and int.
Both q216 and p216 (child being alive) are categorical single select with a dichotomous choice of 1 (yes) and 2 (no).

ros.Count(x=>(x.q216==1)>0 || ros_preg.Count(x=>(x.p216==1)>0
ros.Count(x=>(x.q216==1)==0 || ros_preg.Count(x=>(x.p216==1)==0

I tried this, but still unsuccessful:

ros.Count(x=>(x.q216==1)>0) || ros_preg.Count(x=>(x.p216==1)>0)
ros.Count(x=>(x.q216==1)==0) || ros_preg.Count(x=>(x.p216==1)==0)

I am sure it is problem with parenthesis again but can’t figure out the correct combination. Suggestions are very welcome.

I suppose the fix could be to create a number of intermediate variables:
ros.Count(x=>(x.q216==1)>0
ros.Count(x=>(x.q216==1)==0
But it also gives an error: [WB0027]:Expression has a syntax error.

Any suggestions are very welcome, thank you beforehand.

Vladimir,

write: ROSTERNAME.Count(something)>0
not ROSTERNAME.Count(Something>0)

For novice users I recommend to avoid complex expressions and use more of the intermediate variables.

E.g. define nadults=MEMBERS.Count(m=>m.age>15)

then you can write in enabling or validation conditions: nadults>3

Best, Sergiy Radyakin

Fantastic, thank you!

Dear Gordeev82,

I want to range between number fir this itried below process but unfortunatily its not working ,could you please help me.

HH_roster.Count(m=>m.C05>14) && HH_roster.Count(m=>m.C05<35)

Regrads :
Rakesh

Thank You

Your description is not 100% clear but based on the condition I assume you want to achieve

HH_roster.Count(m=>m.C05>14 && m.C05<35)

or put differently

HH_roster.Count(m=>m.C05.InRange(15,34))

Dear Peter,

I tried to you describe again for your better understanding.Actually I want to count number of person between age group(14 to 35).

In below sentax,
HH_roster is a member details roster and C05 age of respondent question.
so i just want to count between age group (14 to 35) of respondent.

HH_roster.Count(m=>m.C05>14 && m.C05<35)

Please let me know if you want to more under standing.

Thank in advance for your kind support.

In general the syntax I described above should result in the desired count.

You need to be specific if you want to include persons aged 14 and 35 or not in your count. In your description you mentioned

which leads me to believe you want to include persons aged 14/35 respectively. But your earlier condition stated

which would exclude those.

So basically decide if you want to write

HH_roster.Count(m=>m.C05.InRange(15,34))

or

HH_roster.Count(m=>m.C05.InRange(14,35))

its working!
thank you! :+1: