Least fill quota routing on multi-coded questions

Least fill quota routing on multi-coded questions

Summary This document provides examples and explanations of how to create least fill routing set-ups. Both standard multi-coded questions and multi-coded questions in a loop are discussed.
Applies to Askia Design
Written for Scripters and Survey Designers
Keywords Design, least fill, quota, scripts 1.0, scripts 2.0, multi, routing

Table of contents:

Least fill quota routing for a multi-coded question using Askia Scripts 1.0

Download the example .qex file
Download the example task package

Many of you will be familiar with least fill routing i.e. checking quotas and using their values to determine questions to be asked of a respondent.

Below is a basic example of how we would do this for a multi-coded question:

The survey can be tested here:

The first routing checks the selection you've made at S1. For each of those it sets the quota to do values into qotd at the corresponding item iteration in qotdloop.

For items you have not selected at S1 it sets 0 into qotd at the corresponding item iteration.

It can be written like this:

QuotaToDo("item1:" + 1),
QuotaToDo("item2:" + 1),
QuotaToDo("item3:" + 1),
QuotaToDo("item4:" + 1),
QuotaToDo("item5:" + 1),

And as you can see in the example above it can be reduced to this:

QuotaToDo(ResponseText("s1quota1st:" + CI(1)) + ":" + 1)

The second routing sets into Selection Greater Zero those quota to do counts that are currently greater than zero i.e. those quotas that are not closed.

??S1?? intersectionForSet("i",size(??qotdloop??), ( i * (??qotd??[i]>0)) )

The third routing sets into Selection Multiple the items with the three highest quota to do counts that exist in the set selected at S1 for unclosed item quotas.

ForSet("i",3,IndexOfMax(??qotd??,i)) intersection ??Selection Greater Zero??

The 4th to 8th lines of routing simply update the quotas as the respondent exits the survey.

Attached is a task package (Least_Fill_Multicoded.tsk) which can be imported into Supervisor versions 5.3.2 or higher. This will allow you to import the task and quotas in one go and test the survey as live.


Least fill quota routing for a multi-coded question inside a loop using Askia Scripts 2.0

Download the example .qex file
Download the example task package 


This becomes trickier when the question S1 is in a loop already. The set-up has to be amended as the ‘IndexOfMax’ command does not behave in the way we need when it operates in a loop within a loop.

In the example below again has five items but now it is in a loop of three brands.

The routing below returns into variable top3 the items, per brand, that have the three highest quota to do counts.

The first eight lines merely define variables that we will use further on in our code

The section of code below populates arr with the quota to do values of all 5 items in s1.

For i = 1 to intNbResponse
            arr.insert(QuotaToDo("item" + (intStep + i) + ":" + 1))

The following code reorders arr from the most quota to do to the least quota to do and sets it into arrOrdered

For j = 1 to intNbResponse
            arrOrdered = arrOrdered + arr.IndexOfMax(j)
Next j 

Here, the code selects the 3 highest quota to do values from those items selected in s1 and sets them into arrMax3

For k = 1 to 3
            arrMax3 = arrMax3 + (arrOrdered intersection s1)[k]
Next k

‘For k = 1 to 3’ can easily be changed to select the top 1, 2, 4, 5, 100.. etc

Finally, here we return the result we want to set into our top3 variable in the survey

Return arrMax3

itemloop is then linked on all selected responses to top3.

Here the respondent is in a loop of up to five items selected at s1 and also in a loop of three brands.

You can use their responses at this stage to update the quotas for items by brand before they exit the interview. See routings setting value into variables item1 to item15. If they have code 1 at least fill item they will increment the quota by 1.

Attached is a task package that contains a .qes file and its quota set-up for reviewing and testing this example in Supervisor. If your version of Supervisor does not allow importation of task packages then the relevant .qex files are also attached.

The survey can be tested here.

Please note. The example of least fill in a loop does not contain a mechanism to exclude closed quotas from being set into the top3 variable. So for this set up, you can have your top 3 set as all closed quotas and itemloop will be asked for these three selected still.

In the non-loop example this doesn't happen as we have set-up incorporated the Selection Greater Zero variable. It's important to know the distinction in the behaviours.

Have more questions? Submit a request


  • Avatar
    Ashok Nagaraj

    Instead of single punch question can we use the Multi punch question in the questions for least fill.

    Because if we have 50 brands out of that we are choosing only 4 means, we are now creating the 50 single punch questions for each brands.
    This makes little more time consuming and large effort, instead if we have the Multi punch question that accept the Quota in superior and use the same for least fill brand picking.

    Please let me know is this correct or any other suggestions if there.

  • Avatar
    Seyf Altindal

    Hi Ashok,

    The functionality to quota on multi-coded variables is under development. It will be available in Supervisor versions 5.4.X onwards.

    Edited by Seyf Altindal
  • Avatar
    Ashok Nagaraj

    Thanks for update Seyf.