Scoring in / out repeating group

Hello there,

I am using a repeat group and it should include Hidden values inside the repeat group and outside the repeat group to calculate if persons are compliant or not-compliant.
If i only use calculations outside the repeat group i receive following calculation error: error in calculation for /data Xpath nodeset has more than one node [/data] ; cannot covert multiple nodes to a raw vaule.
So to avoid that i put the hidden values in- & outside the repeat group.
These are the steps taken:


In my survey is I asked first one number question to set the amount of iterations
Number question: How many people are interviewed?

After this question a repeat group containing 3 questions is created

[[REPEAT GROUP]]
I asked 3 Multiple choice questions in this repeat group.
question 1: Gender?
Answer: Male or Female

question 2: Pregnant?
Answer: Yes or No
Display condition= " #form/RQ1/Gender = ‘f’ "

question 3: Handling pesticides?
Answer: Yes or No
Display condition= " #form/RQ1/Gender = ‘f’ "

Now i want to give a Non-Compliant (NC) for each woman that is pregnant and handling pesticides, the others are Compliant ©.

So i created a Hidden Value inside the repeat group
if(#form/RQ1/pregnant = ‘preg’ and #form/RQ1/Pesticides = ‘handling’, “NC”, “C”)

So now i know for each iteration if it is compliant or not.

But i want to know the end scoring with one Compliant or Not-Compliant. So if the count of NCs in iterations > 0 the end results should be one NC

This is Hidden Value calculation outside the repeat group using information from inside repeat group.
if(#form/RQ1/HV1 = “NC”, “NC”, “C”)
Than i receive a “C” but it should be “NC”

The other option is:
if(count(#form/RQ1/HV1 = “NC”) > 0, “NC”, “C”)
But this error appears:
Calculation Error: Error in calculation for /data/TNCHV1 uses an invalid reference inside a count function.

How do i proceed further?

Kindest regards,
Nils

Hi,

You are on track with the ‘count’ idea, but need a small change for it to work.

In your current expression, you are providing the count function the entire XPath equality expression

if(count(#form/RQ1/HV1 = “NC”) > 0, “NC”, “C”)

instead you need to provide a filter expression which returns matching elements. I’m not quite sure how your form is set up, but presuming that what you want to count is “The Number of RQ1 Groups which have an HV1 question whose answer is ‘nc’”, that would look like

if(count(#form/RQ1[HV1 = “NC”]) > 0, “NC”, “C”)

-Clayton

Thank you.
I tried and it worked.