Calculate decimal value with select_one only on submit creation

Hi,

In my form, i want to propose a list of target depth (users build a hole), and allow to specify the true achieved depth.
By default, I want to set the achieved depth with the value of selected target depth. With calculation column, it’s ok.
But :

  • If I select a target detph (i.e. 2 m)
  • My Achieved depth is set to ‘2’
  • I edit the achieved depth to ‘2.3’
  • I submit.
  • In data, the achieved depth is 2.3 ; OK
  • If I edit the submission, the achieved depth is ‘2’

There is a way for non change the achieved depth on edit mode (i.e. not use the calculation) ?

Thank’s

xlsform_example.xlsx (22.2 KB)

Hi @jdugh, sorry I deleted my previous incorrect response. If you move your dynamic value from the calculation column to the default column it should fix this :+1:

survey

type name label default
select_one depth TARGET_DEPTH_NUMBER_AVAILABLE Select the target detph
decimal TRUE_DEPTH_ACHIEVED Set the achieved depth ${TARGET_DEPTH_NUMBER_AVAILABLE}

Since KoBo uses your latest deployed form for editing submissions in Enketo, this will also allow you to make changes to submissions before this amendment.

Hi @Josh , thank’s for your reponse.
Unfortunately, this solution does not seem to work.
If I move to default column, when I select a value from the list, my decimal field TRUE_DEPTH_ACHIEVED does not update.
My new test :
select_calculate.xlsx (22.2 KB)
And link to the test on Kobo : Enketo Express for KoBo Toolbox

Hello @Josh,
Could you, please, also explain how the calculation is technically working here.

  • Is it fired on re-open (edit)?
  • Or/and on save?
  • But why not on submit?
  • On validate?
  • On leaving the entry field?
    Kind regards

@wroos, you can refer here for more details on calculation evaluation: Form Logic — ODK Docs

Hi @jdugh, sorry about that — I was testing the edit and forgot to ensure the form still operated correctly. Please try something like this using the trigger column. It seems to do the trick:

survey

type name label calculation trigger
select_one nums num A number
text updated_num Update number ${num} ${num}

choices

list_name name label
nums 1 1
nums 2 2
nums 3 3
nums 4 4
1 Like

Yeah ! This is it !
The last trick who would be great : there is a way to keep the last ${updated_num} submit value ? Even if I change the ${num} value in edit mode ?
I try with adding a calculate question with the calculation : once(${updated_num}). Without success.
Thank you @Josh !

1 Like