I have a long list of integer fields (25 fields) from where I want to calculate the total in the end. I have put all as default=0 to make sure that no "NULL" value is disabling my calculation. When I now use the "tab" to jump from field to field the cursor is placed after the default 0 so the user always has either to go manually before the zero or has to delete the zero before starting to type his own value. I would prefer to have the whole default value selected when reaching the field so it would automatically be overwritten when I start typing. Is there a way to do that? Or is there a different way to make sure I can use the field for my calculations? I was just thinking of using if(${field}!=NULL,...) but that would mean I have to do a 25times nested "if...", right? There must be an easier way...
Thanks for your input!
Solved! Go to Solution.
Hi Nicole
This suggestion originally posted here by James Tedrick might be what you're after:
- if you have a few calculations, you can use the coalesce() function to provide an alternative value if a question is not answered (null) - coalesce(${q1}, 0) will return the value in q1 when present, 0 otherwise
- an alternate formula to coalesce would be: if(string-length(${q1}) = 0, 0, ${q1})
- If you have a large number of calculations, you can add a calculate question after each measurement to store the coalesce or if/string-length function (likely making the bind:esri:fieldType null to not add fields to the table) and use the calculate questions' values instead.
Two other (less elegant) options, using your default 0:
Hope this helps.
Kind regards,
Jim
Hi Nicole
This suggestion originally posted here by James Tedrick might be what you're after:
- if you have a few calculations, you can use the coalesce() function to provide an alternative value if a question is not answered (null) - coalesce(${q1}, 0) will return the value in q1 when present, 0 otherwise
- an alternate formula to coalesce would be: if(string-length(${q1}) = 0, 0, ${q1})
- If you have a large number of calculations, you can add a calculate question after each measurement to store the coalesce or if/string-length function (likely making the bind:esri:fieldType null to not add fields to the table) and use the calculate questions' values instead.
Two other (less elegant) options, using your default 0:
Hope this helps.
Kind regards,
Jim
Thanks a lot! I think I will test with the calculator appearance and hear what our enumerators think about it.
From my experience, you don't have to do:
if(${field}!=NULL,...)
You can simply write:
if(${field},...)