Creating Multiple Data Types in ODK

Hello team, Am trying to create a questionnaire with a date variable and an option to check when the date is not available as per the attached screen-shot. How do I have both appear in my form? The answer should either have the date or one option

Hi Antonny,

I suggest two approaches:

A) Use special dates to signal that the info is either not known or refused (e.g. 01/01/1901 = Don't know, 31/12/1901 = Refused).
This can work if enumerators are accurate in following the instructions and if the date is not expected to be selected as a response. Note that you can also restrict/validate the answer by constraining the date to greater than a specific date or the "special dates" you selected

B) Invert the order of the questions.
Basically you first ask for "Do you know your date of birth (or your age)?" Options: Yes, Don't know, Refused. Then you have a date variable which is relevant only if the previous answer is yes.

C) A third option could be to have a calculated field to validate whether the two variables (date and extra questions) have both been filled, and if so display an error. But I personally think this is slightly less user-friendly.

I hope this is helpful.

Best,
Andrea

1 Like

Hello Antonny,

My organization has faced the same problem. We've created a public Google Sheet which we call "ODK Design Patterns": click to open

In that spreadsheet you'll find a "date and time patterns" worksheet. Look for the example there called "DK month option pattern".

Note that as part of this pattern, we've implemented approach "A" as Andrea described in her post.

If you have any questions, let me know~

1 Like

Hi akissa,
The easiest for me is to split this question. Firts you aske what is you date of birth with 3 option
1 Now the exact date
2 Don't know
3 Refused
If the answer is 1 you show a field for chose the date else you pass
Sorry for my bad english

1 Like

You can accomplish this with two mutually-relevant questions; that is, each question's relevance depends on the other. Specifically

Q1: id=date, type=date, "What is your date of birth?", relevance=" ${select1}='' "

Q2: id=select1, type=select_one, "I do not wish to anwser because", relevance=" ${date}='' "

Basically, as soon as you answer one of the questions, the other one becomes irrelevant, and is therefore hidden. The drawback is that as soon as you answer one of the questions, you cant get the other one back! (eg you change your mind later).