Value Set

Discussions about creating CAPI applications to run on Android devices
Post Reply
Posts: 1
Joined: February 11th, 2020, 5:04 pm

Value Set

Post by clyde16 » February 11th, 2020, 5:11 pm

I want to create a multiple choice question with dynamic values, depending on conditions compared to previous questions
when I put a single choice question it works but multiple choice it does not work!

here is what i do:


      valueset OPERATOR_valueset;

          if pos ("A", Q1)> 0 then
              OPERATOR_valueset.add ("khati", 1);

      setvalueset (OPERATOR, OPERATOR_valueset);

Posts: 245
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Value Set

Post by aaronw » February 13th, 2020, 12:05 pm

Typically I see users wanting to create a dynamic value set from response of a check box. However, you want to create a dynamic value set for a check box.

If your approach is only working for a single choice then the issue is probably that the length of the check box variable is set to 1. The length of a check box variable must be equal to the number of allowable response. However, this has two issues. There isn't a programmatic way to set a variable's length. Even if there was this will muck up data collection, because CSPro partly organizes its data by length.

My approach would be to create a dictionary variable that allows for the maximum number of responses. If you have less responses code the extra ones, so they can be ignored. For example, let's say your check box allows for 5 responses. The valid responses could be "ABCDE" and "UVWXZ" could be ignored.

btri Arjun
Posts: 27
Joined: August 17th, 2018, 6:09 am

Re: Value Set

Post by btri Arjun » February 25th, 2020, 2:38 am

Dear all,

I want to make a dynamic valueset form the previous multiple questions. If Q15 is the question for dynamic valueset then, If Q5 = 1 then Q15 = Cancer, If Q7 = 1 then Q15 = TB, if Q9 = 1 then Q15 = Thyroid …. I tried to make a valueset like this;

valueset diseases;
if Q5 = 1 then diseases ("Cancer”,1);
elseif Q7 = 1 then diseases ("TB",2);
elseif Q9 = 1 then diseases ("Thyroid",3);
setvalueset(Q15, diseases);
but this shows the all values even if Q5 = 2 or Q7 = 2 ……. How is it possible?

Thank you

Posts: 2034
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Value Set

Post by josh » February 25th, 2020, 6:55 am

You need to use diseases.add("Cancer", 1) instead of diseases("Cancer", 1).

Post Reply