Match response integer with table for interpolation

We are collecting data on fish’s growth,
the questions asked to respondent using kobo collect app are.

1. Input the length (cm) of your fish.
2. Input the weight (g) of your fish.

Fish Length (cm) Fish Weight (g)
10 9
15 33
20 80
25 158
30 278
35 448
40 677
45 974
50 1349
55 1811
60 2369
65 3034
70 3816
75 4723
80 5765
85 6953
90 8296
95 9804
100 11488

After respondent enters the inputs, The next steps are,

  1. If the length is not a multiple of 5, then get the 2 nearest lengths (one less than the input length, and another greater than the input length) from the standard table,
  2. Once the 2 nearest lengths are identified, using interpolation the weight is calculated with the weights from table.
  3. the calculated weight is then compared with the input weight
  4. if the input weight is having +/- 10% difference; A note is displayed to the respondent, that the fish are growing fine. if not, it will tell “fish are not growing properly

Apologies ahead, if I am asking too much, I am exploring, and would like to learn from experts.

@imran, this seems interesting. Could you kindly share dummy questions and dummy responses along with the criteria you wish to have? Maybe on that way, the community would be able to understand your issue and help you out.

1 Like

A workaround could be to enhance the table to 1 to 100 cm (=100 rows), with duplicate values for the reference weight (allowing choice duplicates in the settings).

You can then get the corresponding weight with the search() function (or instance Xpath expression). Another option would be to put the weight as choice label and the length as name, so you could use the jr:choice-name() function, see
ODK XForms Specification.

You might also use an external csv file for your length / weight reference table.

Are you using Collect or Enketo (web form)?

2 Likes

Thank you for your suggestion, will try to do that, I am using Kobo Collect.

My objective was to show the respondent, how well their fish was growing compared to standard.

Could you also suggest me on, how can i show it in an effective way?

My first though was to show it in graph, but the community told me that was not possible. hence i am Looking for other workarounds. could you suggest me in that area aswell ?