Linking questions of a form to the answers submitted in a previous form

Hi.
I am trying to create constraints and calculations in a form, based on the answers to a previous form of the same project.

Example 1: Collecting data from vehicle log books (km reading)
In every submission we ask for the km reading at the start and end of a trip. I would like to put a constraint on the answer for trip t+1 so that km_start(trip t+1) is greater than km_end(trip t). For this I need the answer from a previous submission in my current form

Example 2: Collecting fuel data
In every fuel refilling form we ask for the km reading when refilling and for the volume of fuel refilled. I would like to calculate the fuel consumption using the distance made between 2 refills, and therefore between 2 consecutive submissions. If i have submission t and t+1, I would need km(t), km(t+1) and volume refilled (t) inside the form t+1.

Anyone has any idea on how I can do this ?

hi @jbbove ,
The following link may help you
https://support.kobotoolbox.org/dynamic_data_attachment.html

1 Like

Hi Mohammed,
Thanks for sharing. I did check that documentation but it covers how to link projects and data across projects. In my case, I am trying to link submissions to a form and the questions of a form within the same project. In my case I do not have a parent and a child project, but one single project with a unique data set.
Do you know if a project can be both parent and child? Will this feature still work?

Hi @jbbove, you are able to have your project be both the parent and child :slightly_smiling_face:

3 Likes

thanks for the confirmation Josh! I’ll give it a try
Do you maybe have some examples of xls forms that did that and that I could use in case I get stuck?

Hi @jbbove , I have the same inquiry. With the idea of making duplicate the project and link to itself, I have made a simple version project.
child.xlsx (9.6 KB)
parent.xlsx (6.1 KB)
In my example,


parent data include NB1, NB2, NB3. When I use the child data to enter case ID NB4 NB5 with the source ID NB2 NB3, it will fill automatically the source of NB2, NB3 as well as the date they get infected.
at the same time, when i have data in child project with NB4 NB5, i go back to the parent form i just enter case ID NB4, NB5 then the rest will be filled.

If you have better idea, please share with me. I would be really appreciate for that as I try to work on the same idea.