Multiple branches for one question

I have a question at the beginning of my survey with multiple options.
According to the answers of the respondents, they should be redirected to different questions.
Is it possible to use multiple branches for one question ? (in my case 20).
After the question, i added the branch, selected the page I wanted the respondent to be redirected to, and addehd in the display condition ($q11==1) and so on for the other answers. However, it is not working… not showing questions correctly.
Does anyone have an idea on why this is not working for me ?

There are two main methods for controlling display logic. Branching and conditional display. In fact branching is just a special case of conditional display.

Firstly you need to understand that any conditional logic needs to happen after all the dependent values are collected. This usually means branches can be on the same page (as page branching can happen after a ‘next’ click’), but display conditions need to be on subsequent pages (as they system needs to know the condition before drawing the page).

It seems you are on the right track so to answer your question specifically.
a) yes you can have multiple branches, add 20 if you need to. They will be processed in order so the first condition that is true will branch.
b) your logic looks right. I suggest you check that q11 is the correct name - look in the dictionary - if this is a multiple choice question, they data values will be q11_1, q11_2, q11_3 etc. one for each checkbox. If in doubt put a debugging message in a text box.

  1. insert a text box on the next page
  2. click code view (the </>) button
  3. add the following q11 = <span class='expression'>$q11</span>

Then you can see what the value is.

Let us know how you went…

Thank you so much for your reply. Still not working unfortunately. I changed the data values in the multiple choice question with 20 answers but it still does not work.

This is the first branching I did.
Then for each page that the respodent is redirected to, I do another branching. I checked the dictionary and name of questions. All is correct but still the branching is not working

By clicking on “publish” I fond this message :

** Duplicate Data Label [chauffe_eau_annee] . This will still work in SurveyEngine but cause interopability problems with some anaytics and data loss in SPSS exports. Duplicate first found on page 4 but also found on page 8*
** … plus more warnings not shown*

Could it be because I duplicated the pages ? but the names of the pages and of the questions are different so I still do not understand what the problem is

Maybe I can help.
Every data collection item in your survey has a “data label” this is used to determine the name (or names) of variables in your dataset. Simple items like closed and open questions just use the name you give it.
Some data collection items many variables, the data label is used as a prefix - like matrix or multiple choice questions as you are using.

In your case - its simple, you’ve re-used the data label more than once. Tather than disallowing this, there are certain times this is desirable to overwrite a value later in the survey.

Its possible by duplicating a page you’ve also duplicated data collection items. So just find the duplicate items (pages 4 and 8 in your case ) and decide what to do. Both the dictionary and the publish screen will give you some idea where the elements are.

Hope this helps.

Thank you for your reply. Indeed I checked the names of the variables, and in the publish screen I do not have an error message anymore. However, and very bizarre, it still does not work. Should I add the “display condition” twice ? in the branch element and in the question branched to it ?
Like this for example ?

Fred again - again,
Your PERL code has an error. These boxes expect valid self contained PERL. You’re missing an operand between the two
If you mean AND then the code is

($TP_ChauffeEau ==1) && ($appareils_2 ==2)

if you mean OR the code is

($TP_ChauffeEau ==1) || ($appareils_2 ==2)

SurveyEngine is not an ideal platform for debugging these small snippets, instead get your syntax and logic right using a PERL interpreter - like the one at Online Perl Compiler (Interpreter)

I’ve done it for you here:

click to try this in tutorials point here

The test code is below.

Debugging PERL expressions

from Frederic

set up your variables - to simulate the inputs

my $TP_ChauffeEau =1;
my $appareils_2 = 2;

now test it

my $result = ($TP_ChauffeEau ==1) && ($appareils_2 ==2);

and output it

print "the result is ".$result;

Also - a tip - since you have so many conditions - branching will make your survey like a spaghetti junction. Also if you have any overlap of subsets of relevant questions, it will be really unwieldy.

Much easier is to just use conditional displays on your relevant questions.
So put all your questions after this ‘selector question’ then for each relevant question put a conditinal display - likely the same logic you are using.

If a page is empty - SurveyEngine will just draw the next ‘visible page’