Routings and Loops
Go back to the 🔝
- Example 1 : Ask SQ2 only if yes in SQ1 for the L1 loop items 1 &3
- Example 2: Check sum = 100
- Example 3: Ask Q6 only if yes to all iterations of L4
- Example 4: Routing with loop of loop
- Example 5 : Recode each "yes" in the sub-question into a multi coded
Askia provides an original way to deal with sub-questions, question tables and level issues : the loop.
A loop is a question hierarchy and can be handled with at least:
- 1 loop question (eg ^L1^)
- 1 sub-question (eg ^SQ1^ Do you intend to buy the following brand ? Yes, No)
In the question list, a loop is indicated by the icon ,
You can have 4 kinds of loop:
- Question table
- A loop with a selection for each iteration
- A loop with a preliminary selection
- A loop with an iteration count entry
Whatever the kind of loop, you can use the same routing scripts.
If you want to test the routings, you'll find here an 📥 example qex.
Example 1
Ask ^SQ2A^ only if we have "yes" for the ^SQ1A^ and for the ^L1A^ loop items "Ariel" and "Ecover"
Following the loop displayed mode you want, you have 2 possibilities:
A. Chained SQ1A-SQ2A for the same iteration
- L1A is the Question table loop with the following items

- SQ1A is the first sub-question with the items
The routing will be :
Start question | SQ1A |
Condition |
' Loop items 1 ('Ariel') and 3 ('Ecover') L1A.currentiteration has {1;3} and SQ1A.iteration(L1A.currentiteration) has {1} |
Action:
|
SQ2A |
The AskiaScript 'currentiteration' refers to the current iteration of the loop while 'iteration' refers to the iteration of the sub-question.
B. Firstly all items for SQ1B and then only items concerned by the routing for SQ2B
The loop L1B will be a Table question loop with:
- all max visible iterations
and
- the same list of items we have in L1A.
The Loop L1C will be a loop with preliminary selection:
- all max visible iterations
and
- the same list of items we have in L1A.
- linked to the same level as L1B (in order to align result in Analyse for SQ1B and SQ2B)
The routing will be :
Start question | SQ1B |
Condition |
' Loop items 1 ('Ariel') and 3 ('Ecover') L1B.currentiteration has {1;3} and SQ1B.iteration(L1B.currentiteration) has {1} |
Action:
|
Value if true: L1C* + L1B.CurrentIteration Value if False : L1C - L1B.CurrentIteration |
*Value if true : We keep the content of L1C and add the new L1B iteration value
Value if false : if the respondent go back and change the value , we want to remove the previous value from the L1C values
Example 2
We want to check if the sum of SQ3 is = 100% . We propose 2 methods.
A/ Check sum within the loop
The routing will be :
Start question | SQ3 |
Condition |
' We run the script on the latest iteration of the loop (L2.IsLastIteration) and SQ3.allvalues.sum() <>100 |
Action:
|
![]() |
B/ Check Sum outside the loop
We add a chapter 'Sumtest' outside the loop.
The routing will be:
Start question | Sumtest |
Condition |
'we check the sum of SQ4 <> 100 dim sumresult = 0 for i = 1 to L3.responses.count if sumresult <> 100 then |
Action:
|
![]() |
N.B. Whatever the method, we invite you to help the respondent by adding an automatic sum on the screen.
To do it in the example 2A , add a label and insert the following script:
</br></br>
Total remaining % to share :
<b>
!!on(SQ3.allvalues.sum()<>100,
"<span style='color:#DF4335;'>" + (100 - SQ3.allvalues.sum()) + "</span>",
"<span style='color:#00FFC00;'>" + (100 - SQ3.allvalues.sum() )+ "</span>")!!
</b>
In the example 2B, add the script in the Sumtest chapter title:
Total remaining % to share :
<b>
!!on(SQ4.allvalues.sum()<>100,
"<span style='color:#DF4335;'>"+ (100 - SQ4.allvalues.sum()) + "</span>",
"<span style='color:#00FFC00;'>" + (100 - SQ4.allvalues.sum() )+ "</span>")!!
</b>
Example 3
I want to ask Q6 only if the respondent answered yes to all items of the loop L4
Add a chapter outside the loop to set the start question routing.
The routing will be :
Start question | FilQ5 |
Condition |
dim i dim z = L4.responses.count if SQ5.iteration(i) has {1} then if result = z then
|
Action:
|
![]() |
Example 4
Set a routing on loop of loop
The top loop is L5, the sub-loop is L6.
We want to ask SQ8 when top loop (L5) =place2 (2) and sub-loop (L6) = Ecover (3) and SQ7=Yes (1)
To create the routing, you need first to set the iteration wanted . . .
((L6.currentiteration has{3}) and (L5.currentiteration has {2}))
. . . and follow the syntax "QuestionShorcut . iteration(Sub loop:X, Top Loop:Y)"
(SQ7.iteration(L6.currentiteration, L5.currentiteration) has {1})
The routing will be:
Start question | SQ7 |
Condition |
'Top loop = L5((L6.currentiteration has{3}) and (L5.currentiteration has {2})) and (SQ7.iteration(L6.currentiteration, L5.currentiteration) has {1})
|
Action:
|
![]() |
Example 5
We want to recode into a multi-coded (SQ10), each "yes" in the SQ9 sub-question.
Recode each "yes" in the sub-question into a multi coded
Anytime the respondent said yes (SQ9=1) for an iteration of the loop (L7), we want to recode the iteration into the multi coded question (SQ10).
You can set the recode routing in 2 different ways:
a) After each iteration in the loop
The routing will be :
Start question | SQ9 |
Condition |
'loop = L7(SQ9.iteration(L7.currentiteration) has {1})
|
Action:
|
Value if true: SQ10* + L7.CurrentIteration Value if False : SQ10 - L7.CurrentIteration |
*Value if true : We keep the content of SQ10 and add the new L7 iteration value.
Value if false : if the respondent go back and change the value , we want to remove the previous value from the SQ10 values.
b) Outside the loop
The routing will be:
Start question | Recode_SQ10 |
Condition |
True
|
Action:
|
Value if true: ' we declare 2 temporary variables : 'i' and 'result'
|
If you want to test all this routing, you'll find here an 📥 example qex.