Is it possible to choose a default value for a select_one question type depending on another select_one question?
Let’s say I have a select_one question called “category” with the following possible values pulled from choices list:
Cat A
Cat B
New Cat
Then I have another select_one question called “status” with the following values:
Not Changed
Changed
Removed
New
If a user choose “New Cat” for question “category”, I’d like to set “status” to “New”. If the “category” is not “New” (e.g. Cat A, Cat B…), then I’d like to set the default value for “status” to be “Not Changed”.
However, this should happen only once, so that user can change the default value.
If I use a calculation for “status” field, it will always change the value to either “Not Changed” or “New”. I tried applying once() function, but it didn’t work. I tried also adding the calculation expression to the “default” column, but it is not working either (looks like calculations are not supported for “default” column).
I want to preselect the default value for the user depending on another field. However, user should be able to change this value if needed. If I use the calculation, it will be triggered each time the user change another field. I would like to select default value only once, when the field is displayed for the first time. Hope this is more clear
Thanks, this is exactly what I need and what I tried before. My problem is that while it works well in Enketo, it doesn’t work in Collect (Android), because each time a user goes back to Q1, the Q2 will be defaulted to either “Not Changed” or “New”. That’s why I was thinking of using once() in the calculation, to ensure the defaults are applied only in the first attempt…
I don’t see an issue with Collect android app as well. I feel it’s the same way how Enketo behaves. Have you checked the if-statement? It is there exactly how it should be. Correct me if i have mis-understood you.
Hi @janekb
I reworked the logic used by @Kal_Lam incorporating the use of once as suggested by @wroos
I however noticed that you need to correct for when the calculation happens and put them within calculate fields to ensure that the calculations only happen once a choice has been made (see relevant columns). Note, I introduced 4 calculations which are basically hidden (to data collector). I believe two of them could be irrelevant and can be combined However the form should work fine on all platforms i.e. Collect as well as Enketo
Hello @stephanealoo ,
Is this correct, that KoBo meanwhile also allows dynamic defaults? Even expressions?
See https://xlsform.org/en/#default
Is there any difference to once() in behaviour, e.g. activation point?
So, default might also be a solution for the example? (Enketo & KoBoCollect)
Kind regards