Automatic selection of the age group in a multiple choice list

Good evening dear friends!
I have a problem with my form design, especially with a calculation I would like to make.
Indeed, I want to determine (calculate) the age of the respondent according to the year with this formula:
year()-${Year_of_Birth}
Is the formula correct?
My second concern, I would like to automatically select the age range in which the respondent is located, according to his calculated age. I have inserted the following formula, but it displays an error:

’'if(${Age} < 21,1,if((${Age} >= 22 and ${Age} < 30),2,if((${Age} >= 30 and ${Age} < 35,3),if(${Age} >= 35 and ${Age} <40),4,if(${Age}>=41 and ${Age} < 50),5 if(${Age}>50,6 ‘’))))))

Can you help me?
automatic selection of the age group in a multiple choice list.xlsx (5.3 KB)

Finally, is it possible to generate a QR code automatically for each target surveyed?
Attached is the form and the screenshot of the enketo version

@esy_cari2020, FYR, you could follow this post discussed previously:

@esy_cari2020, I could also see some age group being overlapped like (21, 35). Maybe you will also need to fix the criteria.

Your formula used for calculating age also seems OK. But we too have other workarounds to calculate age if you wish to try out.

Sorry, I did not get the last one regarding the QR code. BTW, it’s always good to have a separate topic if you have separate issues. This should help the community with the search index.

1 Like

Hello kal
I have received guidance on the last post on automatic age range selection. However, when I reproduce the same scheme following your guidance of course, the function does not work. I don’t know why?
Nb: I use google sheet


Furthermore, to calculate the age, I want to retrieve the current year, and not define a year myself.
Current age = current year (2022) - Year of birth (year entered by the user)
For precision, I want the current year to be updated systematically over the years.

Merci
Form_collecteurs_V2.1.xlsx (24.9 KB)

@esy_cari2020, you should be able to calculate the age as you wish by following this post discussed previously:

1 Like