Quota methods available for the question object

Available from version 5.4.4.

In AskiaScript, the predefined quota methods keywords that are available for the question object can be used to execute queries in the AskiaField engine, in order to obtain information about quotas. These methods are located within the global scope, so are available everywhere in AskiaScript. They are associated with the question object.

Quotas are selected using the minimum number to be done, except if that is higher than the maximum number allowed. Therefore, we combine looking for the worst-case scenario (looking for the maximum to do while using the minimum target, keeping in mind the minimum allowed using the maximum target).

A quota category is a set of questions and responses, and not a path in the quota tree. Therefore, no matter what the structure of the quota tree is, the category only describes a set of questions and responses. This means that you do not have to know what the quota tree looks like as you will always get a usable response. This also means that if the quota tree changes, the routing will always keep working.

See notes below.

In this topic:

Notes

Category [Optional]

Difference between AvailableQuota() and OpenQuota():

Let’s image a simple quota tree like this – we want to know which Product we should test (A, B or C)

 

 

Target

Observed

ToDo

Total

 

30

6

24

Product A

 

8

6

2

 

Male

6

6

0

 

Female

2

0

2

Product B

 

10

0

10

 

Male

5

0

5

 

Female

5

0

5

Product C

 

12

0

12

 

Male

6

0

6

 

Female

6

0

6

 

For males, the To do results are (0,5,6) and the result is {3;2}

For females, the results are (2,5,6) and the result is {3;2;1}

And if the gender is known, Product.AvailableQuota() or Product.OpenQuota() will give you the right response

And if the gender is not yet known, AskiaScript lets you explore hypothesis: 

You can call Product.AvailableQuota(Gender:1) (returning {3;2}) or Product.AvailableQuota(Gender:2) (returning {3;2;1})

You can also call Product.OpenQuota(Gender:1) (returning {3;2}) or Product.OpenQuota(Gender:2) (returning {3;2;1})

So if the gender is not known, Product.AvailableQuota() will look into Product A, will realise that one more man would make you go over quota and will therefore declare that it cannot take the risk to leave Product A open. And the result will be {3;2}

And Product.OpenQuota() will look into Product A, will realise that the female are still open and the result will be {3;2;1}

 Calculation for the balanced quotas keywords

 

 

Target

Observed

ToDo

Total

 

30

15

15

Product A

 

8

6

2

 

Male

6

5

1

 

Female

2

1

1

Product B

 

10

5

5

 

Male

5

2

3

 

Female

5

3

2

Product C

 

12

4

8

 

Male

6

2

4

 

Female

6

2

4

 

Using the example above, if we call Product.BalancedQuotaList("Gender:2") or any balanced quota keywords. Then the calculation will be:

((MinRowTarget / MinimumTargetBaseOfVariable) - (Observed / ObservedBaseOfVariable)) * 100

Here on our example:

For Product A:

((2 / 8) - (1 / 6)) * 100 = 8.333333

For Product B:

((5 / 10) - (3 / 5)) * 100 = -10

For Product C:

((6 / 12) - (2 / 4)) * 100 = 0

Then we order from the max to the min so the result is {1;3;2} so A C B

↑ Top of page ↑

Methods

Note: Quota methods can be applied to closed questions, but not numerical or calculated questions.

For grouped responses, the methods will always return the full list of responses. For example:

Age question with 3 responses:

One response group created for age 25 and above:

If the response Less than 25 has still 100 interviews to do, and the group 25 and above has still 150 to do, and you use the following script:

Age.AvailableQuota()

... you will get the following result:

{2;3;1}

↑ Top of page ↑

OpenQuota( [Category])

Available from version 5.6.0.

List of indexes of the responses of the TargetQuestion still open ( to do > 0), and sorted from the max to-do to the min to-do, using the count for the sort.

Returns an Array.

Examples
' The quota tree is: Gender x Age x Region
'
 Search the open quota responses for the question 'Age', 
' in the first 'Region' level and for the 'Man'
Age.OpenQuota(Region : 1, Gender : 1) ' => {3; 2; 5}
'
 Search the open quota responses for the question 'Age', 
' in the first, third, fourth or fifth 'Region' level and for the 'Man'
Age.OpenQuota(Region : {1;3 to 5}, Gender : 1) ' => {3; 2; 6}
'
 Search the open quota responses for the question 'Age', 
' in the 'Region' level with the entry code 3 
' and the 'Gender' with the entry code 7
Age.OpenQuota(Region : "3", Gender : "7") ' => {3; 2; 5}
'
 Search the open quota responses for the question 'Age', 
' in the 'Region' level with the entry code 3 or 5 
' and the 'Gender' with the entry code 7
Age.OpenQuota(Region : {"3";"5"}, Gender : "7") ' => {3; 2; 5}

↑ Top of page ↑

OpenBalancedQuota( [Category])

Available from version 5.6.0.

List of indexes of the responses of the TargetQuestion still open ( to do > 0), and sorted from the max to the min, using the following formula for the sort:

(Target% - Observed%)

Returns an Array.

Examples
' The quota tree is: Gender x Age x Region
'
 Search the open quota responses for the question 'Age', 
' in the first 'Region' level and for the 'Man'
Age.OpenBalancedQuota(Region : 1, Gender : 1) ' => {3; 2; 5}
'
 Search the open quota responses for the question 'Age', 
' in the first, third, fourth or fifth 'Region' level and for the 'Man'
Age.OpenBalancedQuota(Region : {1;3 to 5}, Gender : 1) ' => {3; 2; 6}
'
 Search the open quota responses for the question 'Age', 
' in the 'Region' level with the entry code 3 
' and the 'Gender' with the entry code 7
Age.OpenBalancedQuota(Region : "3", Gender : "7") ' => {3; 2; 5}
'
 Search the open quota responses for the question 'Age', 
' in the 'Region' level with the entry code 3 or 5 
' and the 'Gender' with the entry code 7
Age.OpenBalancedQuota(Region : {"3";"5"}, Gender : "7") ' => {3; 2; 5}

↑ Top of page ↑

AvailableQuota( [Category])

List of indexes of the responses of the TargetQuestion still available ( to do > 0), and sorted from the max to-do to the min to-do, using the count for the sort.

Returns an Array.

For a detailed example of using AvailableQuota, see the Knowledge Base article Quota Logic Examples in Design.
Examples
' The quota tree is: Gender x Age x Region
'
 Search the available responses for the question 'Age', 
' in the first 'Region' level and for the 'Man'
Age.AvailableQuota(Region : 1, Gender : 1) ' => {3; 2; 5}
'
 Search the available responses for the question 'Age', 
' in the first, third, fourth or fifth 'Region' level and for the 'Man'
Age.AvailableQuota(Region : {1;3 to 5}, Gender : 1) ' => {3; 2; 6}
'
 Search the available responses for the question 'Age', 
' in the 'Region' level with the entry code 3 
' and the 'Gender' with the entry code 7
Age.AvailableQuota(Region : "3", Gender : "7") ' => {3; 2; 5}
'
 Search the available responses for the question 'Age', 
' in the 'Region' level with the entry code 3 or 5 
' and the 'Gender' with the entry code 7
Age.AvailableQuota(Region : {"3";"5"}, Gender : "7") ' => {3; 2; 5}

↑ Top of page ↑

AvailableBalancedQuota( [Category])

List of indexes of the responses of the TargetQuestion still available ( to do > 0), and sorted from the max to the min, using the following formula for the sort:

(Target% - Observed%)

Returns an Array.

For a detailed example of using AvailableQuota and AvailableBalancedQuota, see the Knowledge Base article Quota Logic Examples in Design.
Examples
' The quota tree is: Gender x Age x Region
'
 Search the available responses for the question 'Age', 
' in the first 'Region' level and for the 'Man'
Age.AvailableBalancedQuota(Region : 1, Gender : 1) ' => {3; 2; 5}
'
 Search the available responses for the question 'Age', 
' in the first, third, fourth or fifth 'Region' level and for the 'Man'
Age.AvailableBalancedQuota(Region : {1;3 to 5}, Gender : 1) ' => {3; 2; 6}
'
 Search the available responses for the question 'Age', 
' in the 'Region' level with the entry code 3 
' and the 'Gender' with the entry code 7
Age.AvailableBalancedQuota(Region : "3", Gender : "7") ' => {3; 2; 5}
'
 Search the available responses for the question 'Age', 
' in the 'Region' level with the entry code 3 or 5 
' and the 'Gender' with the entry code 7
Age.AvailableBalancedQuota(Region : {"3";"5"}, Gender : "7") ' => {3; 2; 5}

↑ Top of page ↑

QuotaList( [Category])

Complete list of indexes of the responses of the TargetQuestion, sorted from the max to-do to the min to-do, using the count for the sort.

Returns an Array.

Examples
' The quota tree is: Gender x Age x Region
'
 Search the list of responses for the question 'Age', 
' in the first 'Region' level and for the 'Man'
Age.QuotaList(Region : 1, Gender : 1) ' => {3; 2; 4; 1; 6; 5}
'
 Search the list of responses for the question 'Age', 
' in the first, third, fourth or fifth 'Region' level and for the 'Man'
Age.QuotaList(Region : {1;3 to 5}, Gender : 1) ' => {3; 2; 1; 5; 4; 6}
'
 Search the list of responses for the question 'Age', 
' in the 'Region' level with the entry code 3 
' and the 'Gender' with the entry code 7
Age.QuotaList(Region : "3", Gender : "7") ' => {3; 2; 4; 1; 6; 5}
'
 Search the list of responses for the question 'Age', 
' in the 'Region' level with the entry code 3 or 5 
' and the 'Gender' with the entry code 7
Age.QuotaList(Region : {"3";"5"}, Gender : "7") ' => {3; 2; 4; 1; 6; 5}

↑ Top of page ↑

BalancedQuotaList( [Category])

Complete list of indexes of the responses of the TargetQuestion, sorted from the max to the min, using the following formula for the sort:

(Target% - Observed%)

Returns an Array.

Examples
' The quota tree is: Gender x Age x Region
'
 Search the list of responses for the question 'Age', 
' in the first 'Region' level and for the 'Man'
Age.BalancedQuotaList(Region : 1, Gender : 1) ' => {3; 2; 4; 1; 6; 5}
'
 Search the list of responses for the question 'Age', 
' in the first, third, fourth or fifth 'Region' level and for the 'Man'
Age.BalancedQuotaList(Region : {1;3 to 5}, Gender : 1) ' => {3; 2; 1; 5; 4; 6}
'
 Search the list of responses for the question 'Age', 
' in the 'Region' level with the entry code 3 
' and the 'Gender' with the entry code 7
Age.BalancedQuotaList(Region : "3", Gender : "7") ' => {3; 2; 4; 1; 6; 5}
'
 Search the list of responses for the question 'Age', 
' in the 'Region' level with the entry code 3 or 5 
' and the 'Gender' with the entry code 7
Age.BalancedQuotaList(Region : {"3";"5"}, Gender : "7") ' => {3; 2; 4; 1; 6; 5}

↑ Top of page ↑

Create your own Knowledge Base