How do we automatically input the value entered from a previous variable to the next variable?

Hello…
I am newbie here…

I’m building a health research form.

there is a question about the gestational age of the mother
with numeric answers (in weeks) [B5_GA]

then there are more questions

is the pregnancy between 20-40 weeks [E3_RA]? yes and no answer

is it possible that Kobo can make an automatic answer from the question [B5_GA] for [E3_RA]?

Thank you

Hi @dy10,

Welcome to the community! You could do the same by following the instructions as outlined in the image below:

In the xlsform survey tab:
Image%201

Reference xlsform:
auto-fill preloaded information.xlsx (9.8 KB)

GOOD DAY!

1 Like

thank Kal_Lam for the answer but i mean like image below ::

Hi @dy10,

Please follow the instructions as outlined in the image below. It has 2 different options:

In the survey sheet of the xlsform:

In the choices sheet of the xlsform:
Image%202

Reference xlsform:
auto-fill preloaded information v2.xlsx (10.8 KB)

GOOD DAY!

1 Like

Where should I put the formula?
Is the validation code or skip logic?

thanks

Hi @dy10,

You should type the formula under the calculation column as shown in the figure above. For reference, please see the attached xlsform.

GOOD DAY!

Dear @dy10,
it is in the calculation column (as in @Kal_Lam example…

If your calculated variable can not be changed by the user, the type should better be “calculate” (or set as read_only = yes, if you want to show it).
Side-note: If possible, I would prefer to do calculations not KoBo, but after data export.)

There might be 2 small problems with the example from Kai.

  1. With your type “select_one …” the user can still change the calculated variable,
  2. If the Gestatiional age is empty, the calculation wou[d also produce No (2), but might better be empty.

I add an example for two other options. Esp. in case you want the automatic calculation only if the Gestatiional age is set (not empty). But you want the user to answer (yes or no), if the Gestatiional age is empty.

AutoFill v2.xlsx (11.1 KB)

Kind regards
Wolfgang

2 Likes

Thanks a lot wroos and Kal_Lam.

It’s work

1 Like