Default number is not appearing

Hi Team,

In my form, I have three number questions, even though it is calculated in the calculate questions in Enketo view, it will return empty when you want to review the form or download the data. I check the previous topics in community it was for sting values.

aAmXEetzEYEhehoio4EJPp (3).xlsx (10.5 KB)

WhatsApp Image 2023-10-06 at 10.04.00

You need coalesce() if one of the calculation elements might be empty. ODK XForms Specification.

And you might need to cast string elements to number, using the number() function. ODK XForms Specification.

Could you share the related part of your form, please?

1 Like

@wroos hi,

It works in the Enkote web typically, it shouldn’t be empty if skip logic is applied, it should be filled as 3 as the default value.

Form: aAmXEetzEYEhehoio4EJPp (3).xlsx (10.5 KB)

Sorry, your form extract attached shows errors on Online validator.
I made another version, which seems to work as expected, including the default.
Dis02.xlsx (10.5 KB)

As far as I know, in Enketo defaults are set on form load, but would be removed for non-relevant fields on submission.
(For Collect, see Form Logic - ODK Docs)

  1. Initially

  2. NO selected

  3. Saved & reload (Enketo)

  1. By submission (or validate in Preview) the Sum is cleaned if Disability is not relevant.

    (The case with values 5 has been manually edited before.)

The example also shows differences between Enketo and Collect: Cleaning for relevant (and linked sum update) only seems to happen through submission in Enketo, but on save. In Collect cleaning seems to happens on save (and update for sum already on swipe/immediately!) in Collect! Also the time/behaviour of initial default setting seems different! (Even see navigation)

So, a better form design would need to add a relevant to the sum (the initial sum might still be calculated, but at least not shown, and the sum would be cleaned to empty through submission (or Collect save already).

1 Like