Scoring in CommCare

Hi All,

I am getting a build error with the following if statement. The error says
there are only two arguments when we need three.

if(/data/duration <= “10”,“1”, if(/data/duration>“10” and
/data/duration<=“20”, “2”), if(/data/duration>“20”, “3”))

What I want is to calculate a score. It will equal 1 if duration is <=10, 2
if duration is between 10 and 20, and 3 if duration is greater than 20.
Duration is captured in another question called duration.

How do I resolve this?

Thanks,
Sangya

you want:

if(/data/duration <= 10, “1”, if(/data/duration <= 20, “2”, “3”))

every if() needs 3 arguments: (1) the condition, (2) what to do if the
condition is true, (3) what to do if the condition is false

··· On Mon, Dec 9, 2013 at 12:40 PM, Sangya Kaphle wrote:

Hi All,

I am getting a build error with the following if statement. The error says
there are only two arguments when we need three.

if(/data/duration <= “10”,“1”, if(/data/duration>“10” and
/data/duration<=“20”, “2”), if(/data/duration>“20”, “3”))

What I want is to calculate a score. It will equal 1 if duration is <=10,
2 if duration is between 10 and 20, and 3 if duration is greater than 20.
Duration is captured in another question called duration.

How do I resolve this?

Thanks,
Sangya


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/groups/opt_out.

Thanks Drew!!
Will this not score anything less than 20 as 2 because of the second
statement or the first if statement takes care of that?

··· On Mon, Dec 9, 2013 at 1:43 PM, Drew Roos wrote:

you want:

if(/data/duration <= 10, “1”, if(/data/duration <= 20, “2”, “3”))

every if() needs 3 arguments: (1) the condition, (2) what to do if the
condition is true, (3) what to do if the condition is false

On Mon, Dec 9, 2013 at 12:40 PM, Sangya Kaphle skaphle@dimagi.com wrote:

Hi All,

I am getting a build error with the following if statement. The error
says there are only two arguments when we need three.

if(/data/duration <= “10”,“1”, if(/data/duration>“10” and
/data/duration<=“20”, “2”), if(/data/duration>“20”, “3”))

What I want is to calculate a score. It will equal 1 if duration is <=10,
2 if duration is between 10 and 20, and 3 if duration is greater than 20.
Duration is captured in another question called duration.

How do I resolve this?

Thanks,
Sangya


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/groups/opt_out.


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/groups/opt_out.

yeah, if it’s less than 10 you never get to the 2nd if() at all

··· On Mon, Dec 9, 2013 at 12:45 PM, Sangya Kaphle wrote:

Thanks Drew!!
Will this not score anything less than 20 as 2 because of the second
statement or the first if statement takes care of that?

On Mon, Dec 9, 2013 at 1:43 PM, Drew Roos droos@dimagi.com wrote:

you want:

if(/data/duration <= 10, “1”, if(/data/duration <= 20, “2”, “3”))

every if() needs 3 arguments: (1) the condition, (2) what to do if the
condition is true, (3) what to do if the condition is false

On Mon, Dec 9, 2013 at 12:40 PM, Sangya Kaphle skaphle@dimagi.comwrote:

Hi All,

I am getting a build error with the following if statement. The error
says there are only two arguments when we need three.

if(/data/duration <= “10”,“1”, if(/data/duration>“10” and
/data/duration<=“20”, “2”), if(/data/duration>“20”, “3”))

What I want is to calculate a score. It will equal 1 if duration is
<=10, 2 if duration is between 10 and 20, and 3 if duration is greater than
20. Duration is captured in another question called duration.

How do I resolve this?

Thanks,
Sangya


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/groups/opt_out.


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/groups/opt_out.


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/groups/opt_out.