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

Hello Kal;
Sorry to come back to it, but I’ve been trying for several months this formula which is essential for me, but I can’t do it? I can’t identify the error either; yet it worked well in the previous form.
Please help me please!
1- when the age is less than 15, then it automatically ticks modality 1
2- when the age is between 15 and 29, it automatically selects modality 2
3- when the age is over 30, then it automatically selects modality 3.
Here is the principle of my request!
Thanks

hello family
Form_collecteur_draft.xlsx (19.7 KB)
Form_collecteur-C.xlsx (19.9 KB)
Sorry to come back to it, but I’ve been trying this formula for several months, which is essential for me, but I can’t do it? I can’t identify the error either; yet it worked well in the previous form.
Please help me please! I’m really stuck on this project because of this formula!

1- when the age is less than 15, then it automatically ticks modality 1
2- when the age is between 15 and 29, it automatically selects modality 2
3- when the age is over 30, then it automatically selects modality 3.
Here is the principle of my request!

@esy_cari2020, did you have a chance to play around with the post shared previously? The workaround should help you solve your issue.