An addition to explain this equation.
Let's say you coded like this
sex:
1: male
2: female
age:
1: 0-19
2: 20-29
3: 30-39
4: 40-49
5: 50-59
6: 60+
Except the quotas with limit 0 for the too young and too old people, you have 6 groups
1: male and age between 20 and 39
2: male and age between 40 and 49
3: male and age between 50 and 59
4: female and age between 20 and 39
5: female and age between 40 and 49
6: female and age between 50 and 59
Now a little bit of school artithmetic.
The same age group is either in quota group "1" or "4", "2" or "5", -> X or X+3 depending on sex.
(sex-1) is either "0" or "1"
(sex-1)*3 is either "0" or "3"
if there wasn't this "double" age group you could have proceed with something like (sex-1)*3 + age-1
Now you have to use a nested IF:
{if(age==2 or age=
,(sex-1)*3+1,if(age==4,(sex-1)*3+2,if(age==5,(sex-1)*3+3,'')))}
For age=2 or age=3 the result is either "1" or "4"
For age=4 the result is either "2" or "5"
For age=5 the result is either "3" or "6"
To avoid this nested IF you could use assessment mode like this.
Here you use the advantage to have the same assessment value for different answer options.
Now this is sufficient
{(sex-1)*3 + age.valueNAOK}
Joffm