Conditional calculation "if statement"

Hello Team,
Hope you're all doing fine today. I'm struggling witih calculation formula.

1. What is the issue? Please be detailed.
I have :

  • a barcode reader which return a value, $(barcode)
  • a select_one from list from which I can calculate the $(uuidEleve)

2. What steps can we take to reproduce this issue?
The objective is to identify a person by scanning the QR Code, but if it's not readable, we select from the list.

3. What have you tried to fix the issue?
type = calculate
name = codeEleve
calculation = if(string-length(${barcode})=0,'$(uuidEleve)','$(barcode)')
I can't get it work.

4. Upload any forms or screenshots you can share publicly below.

May you please help.
Thanks

Would you mind to share a reduced (minimal) form example/extract, please, as XLSForm?

Try:

if(string-length(${barcode})=0,${uuidEleve},${barcode})

1 Like

I tried this before, same results. I get an error in odkcollect


I can't even upload the form when I remove the quotes


elevesMinimals.csv (195 Bytes)
Consultation des Bénéficiaires_Minimal.xlsx (510.3 KB)

Here is the sample of my XLSform

Edit, misread. Sorry

Not only removing the quote, you should use curly bracket instead of round bracket.

${}, not $()

1 Like

:sweat_smile:
I spent hours trying to figure out what was wrong in my calculation. This is what happens when you switch from one language to another all day long.
Thanks a lot for your support !