Referring to a variable based on response to another variable

form-design

#1

I have been learning a lot about ODK while trying to implement the form I am currently working on, but this problem has stumped me. I have a set of 8 questions, which are numbered v1 through v8. Following these questions, I have a question (var_ref) that asks users to select a number 1-8. Based on their response to var_ref, I want to reference the values stored in v1, v2, v3, etc.

I have attached a simple example form for the problem I am encountering. I think some form of calculation in num_ref is necessary. I tried things like calculate = ${v${var_ref}} but I suppose this kind of nesting of variable calls is not allowed. I wonder if I need to use concat or join here, but I am not sure. I am open to any ideas or suggestions you may have.

Thanks!

extract_test.xlsx (9.8 KB)


(Grzegorz Orczykowski) #2

Hi @Brenton_Peterson
as I know such a calculation is not allowed. You would need to use if-else statement. Please take a look ate your edited form:
extract_test.xlsx (8.3 KB)
I know it's not convenient way but probably the only one.


#3

Hi Grzegorz,

Thanks for your suggestion -- that works really well. While an -if- statement might be cumbersome with many variables, it is pretty manageable for my case (8 variables). This worked perfectly for me. Thanks again!

Brenton