Calculation Help

Dear Community,

I am trying to make a form that gives a score at the end of all the
questions with one mark for yes and zero mark for no. However some of
the questions may be non applicable (NA) and am looking for a way of
reducing the total number of applicable questions with any questions that
are answered not applicable.

See form attached I have 10 questions if 7 are answered yes and all are
applicable then the score is 70%, however if 2 were non applicable then the
score should be 7/(10-2).

  1. How do I make the form recognize the 2 NA and take care of them in the
    percentage score?
  2. How do I list the questions that had no as an answer.?

see xls below
survey
type name label hint constraint calculation relevant default readonly
appearance required media::image bind:jr:constraintMsg
select_one yes_no_na q1 Are you available?
select_one yes_no_na q2 do you have a test?
select_one yes_no_na q3 did you carry it out?
select_one yes_no_na q4 how far sis you get?
select_one yes_no_na q5 was he there?
select_one yes_no_na q6 did he come?
select_one yes_no_na q7 was he lost?
select_one yes_no_na q8 was he found?
select_one yes_no_na q9 did he come?
select_one yes_no_na q10 was he there?
calculate totsc Total score
${q1}+${q2}+${q3}+${q4}+${q5}+${q6}+${q7}+${q8}+${q9}+${q10}
calculate yesper yes percentage ${totsc}div10*100
note yesper1 Percentage score: ${yesper} %
note noque Questions answered No :

choices
list name name label image
yes_no_na 1 Yes
yes_no_na 0 No
yes_no_na 99 N/A
yes_no 1 Yes
yes_no 0 No

HI there,
I can't see an easy way to do this.

The long and complicated way is:

create 10 new calculates. Each re-codes one of your answers using an 'if' statement like this:

if(${q1}='99',0,${q1})

then change 'totsc' so it adds together these 10 calculates instead of the questions themselves. This will give the total number of 'yes' answers.

For the total number of valid (ie non-NA) answers, create another 10 calculates, each one re-codes a question like this
if(${q1}='99',0,1)
then add them together with another calculate 'valid' to get the total number of valid answers. Then divide 'totsc' by 'valid' to get fraction/percentage.

To get number of 'no' answers, subtract 'totsc' from 'valid'

Cheers,

Matt

··· On Sunday, 18 December 2016 08:55:26 UTC+11, Wazamo wrote: > Dear Community, > > > I am trying to make a form that gives a score at the end of all the questions with one mark for yes and zero mark for no. However some of the questions may be non applicable (NA) and am looking for a way of reducing the total number of applicable questions with any questions that are answered not applicable. > > > See form attached I have 10 questions if 7 are answered yes and all are applicable then the score is 70%, however if 2 were non applicable then the score should be 7/(10-2). > > > 1. How do I make the form recognize the 2 NA and take care of them in the percentage score? > 2. How do I list the questions that had no as an answer.? > > > see xls below > survey > > > > > > > > type > name > label > hint > constraint > calculation > relevant > default > readonly > appearance > required > media::image > bind:jr:constraintMsg > > > > > > > > > > > > > > > > > > > select_one yes_no_na > q1 > Are you available? > > > > > > > > > > > > > > select_one yes_no_na > q2 > do you have a test? > > > > > > > > > > > > > > select_one yes_no_na > q3 > did you carry it out? > > > > > > > > > > > > > > select_one yes_no_na > q4 > how far sis you get? > > > > > > > > > > > > > > select_one yes_no_na > q5 > was he there? > > > > > > > > > > > > > > select_one yes_no_na > q6 > did he come? > > > > > > > > > > > > > > select_one yes_no_na > q7 > was he lost? > > > > > > > > > > > > > > select_one yes_no_na > q8 > was he found? > > > > > > > > > > > > > > select_one yes_no_na > q9 > did he come? > > > > > > > > > > > > > > select_one yes_no_na > q10 > was he there? > > > > > > > > > > > > > > calculate > totsc > Total score > > > ${q1}+${q2}+${q3}+${q4}+${q5}+${q6}+${q7}+${q8}+${q9}+${q10} > > > > > calculate > yesper > yes percentage > > > ${totsc}div10*100 > > > > > > > > > > note > yesper1 > Percentage score: ${yesper} % > > > > > > > > > > > > > > note > noque > Questions answered No : > > > > > > > > > > > > > > > choices > > > > > > > list > name > name > label > image > > > yes_no_na > 1 > Yes > > > > yes_no_na > 0 > No > > > > yes_no_na > 99 > N/A > > > > > > > > > > yes_no > 1 > Yes > > > > yes_no > 0 > No

This is an interesting problem and I think, as is often the case in the
type of calculation where a recode of sorts is necessary, modulo can be of
use.

If you are open to re-coding the way your value lists are programmed, I
think you can get what you need in a single calculation.

Basically you need it to sort out like this:
Numerator: Yes = 1, No = 0, NA = 0
Denominator: Yes = 1, No = 1, NA = 0

Then you can just add those two up and divide them. So the question is how
do you get a single set of responses to code in two different ways, and I
think the answer is modulo calculations. Here is an example table

CODE

NUM

DNM

Y 1 1 1
N 3 0 1
NA 0 0 0
MOD 3 2
The first column represents the code value you would need to use in your
code list.
The last row represents the modulo values you'd need to use in the calc.
The second column represents the numerator outputs from the calculation and
the 3rd represents the denominator outputs.

So basically you'd need to set up calcs like this:

((${q1} mod 3) + (${q2} mod 3) + (${q4} mod 3) + etc...) div ((${q1} mod 2)

  • (${q2} mod 2) + (${q3} mod 2) + etc...)). If the code values suggested
    above are used, this should yield the dynamic % calc you are looking for.

Jason

··· On Saturday, December 17, 2016 at 4:55:26 PM UTC-5, Wazamo wrote: > > Dear Community, > > I am trying to make a form that gives a score at the end of all the > questions with one mark for *yes* and zero mark for *no*. However some of > the questions may be non applicable (NA) and am looking for a way of > reducing the total number of applicable questions with any questions that > are answered not applicable. > > See form attached I have 10 questions if 7 are answered yes and all are > applicable then the score is 70%, however if 2 were non applicable then the > score should be 7/(10-2). > > 1. How do I make the form recognize the 2 NA and take care of them in the > percentage score? > 2. How do I list the questions that had *no* as an answer.? > > see xls below > survey > type name label hint constraint calculation relevant default readonly > appearance required media::image bind:jr:constraintMsg > select_one yes_no_na q1 Are you available? > select_one yes_no_na q2 do you have a test? > select_one yes_no_na q3 did you carry it out? > select_one yes_no_na q4 how far sis you get? > select_one yes_no_na q5 was he there? > select_one yes_no_na q6 did he come? > select_one yes_no_na q7 was he lost? > select_one yes_no_na q8 was he found? > select_one yes_no_na q9 did he come? > select_one yes_no_na q10 was he there? > calculate totsc Total score > ${q1}+${q2}+${q3}+${q4}+${q5}+${q6}+${q7}+${q8}+${q9}+${q10} > calculate yesper yes percentage ${totsc}div10*100 > note yesper1 Percentage score: ${yesper} % > note noque Questions answered No : > > choices > list name name label image > yes_no_na 1 Yes > yes_no_na 0 No > yes_no_na 99 N/A > yes_no 1 Yes > yes_no 0 No >

Thanks Jason! A much more elegant solution than my messy hack.

··· On 21 Dec 2016 3:57 am, "Jason Ives" wrote:

This is an interesting problem and I think, as is often the case in the
type of calculation where a recode of sorts is necessary, modulo can be of
use.

If you are open to re-coding the way your value lists are programmed, I
think you can get what you need in a single calculation.

Basically you need it to sort out like this:
Numerator: Yes = 1, No = 0, NA = 0
Denominator: Yes = 1, No = 1, NA = 0

Then you can just add those two up and divide them. So the question is
how do you get a single set of responses to code in two different ways, and
I think the answer is modulo calculations. Here is an example table

CODE

NUM

DNM

Y 1 1 1
N 3 0 1
NA 0 0 0
MOD 3 2
The first column represents the code value you would need to use in your
code list.
The last row represents the modulo values you'd need to use in the calc.
The second column represents the numerator outputs from the calculation
and the 3rd represents the denominator outputs.

So basically you'd need to set up calcs like this:

((${q1} mod 3) + (${q2} mod 3) + (${q4} mod 3) + etc...) div ((${q1} mod
2) + (${q2} mod 2) + (${q3} mod 2) + etc...)). If the code values
suggested above are used, this should yield the dynamic % calc you are
looking for.

Jason

On Saturday, December 17, 2016 at 4:55:26 PM UTC-5, Wazamo wrote:

Dear Community,

I am trying to make a form that gives a score at the end of all the
questions with one mark for yes and zero mark for no. However some
of the questions may be non applicable (NA) and am looking for a way of
reducing the total number of applicable questions with any questions that
are answered not applicable.

See form attached I have 10 questions if 7 are answered yes and all are
applicable then the score is 70%, however if 2 were non applicable then the
score should be 7/(10-2).

  1. How do I make the form recognize the 2 NA and take care of them in the
    percentage score?
  2. How do I list the questions that had no as an answer.?

see xls below
survey
type name label hint constraint calculation relevant default readonly
appearance required media::image bind:jr:constraintMsg
select_one yes_no_na q1 Are you available?
select_one yes_no_na q2 do you have a test?
select_one yes_no_na q3 did you carry it out?
select_one yes_no_na q4 how far sis you get?
select_one yes_no_na q5 was he there?
select_one yes_no_na q6 did he come?
select_one yes_no_na q7 was he lost?
select_one yes_no_na q8 was he found?
select_one yes_no_na q9 did he come?
select_one yes_no_na q10 was he there?
calculate totsc Total score ${q1}+${q2}+${q3}+${q4}+${q5}+
${q6}+${q7}+${q8}+${q9}+${q10}
calculate yesper yes percentage ${totsc}div10*100
note yesper1 Percentage score: ${yesper} %
note noque Questions answered No :

choices
list name name label image
yes_no_na 1 Yes
yes_no_na 0 No
yes_no_na 99 N/A
yes_no 1 Yes
yes_no 0 No

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to a topic in the
Google Groups "ODK Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/
topic/opendatakit/r2b_YuB1N1g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.