Hello Team,
Kindly assist me, I am trying to calculate a total value depending on the species of fish chosen from the group and the weight and value-filled.
Right now it’s not populating.
aPsmJkcegnRGTVvBmfTnZH.xlsx (11.2 KB)
Hello Team,
Kindly assist me, I am trying to calculate a total value depending on the species of fish chosen from the group and the weight and value-filled.
Right now it’s not populating.
aPsmJkcegnRGTVvBmfTnZH.xlsx (11.2 KB)
Hi @zachzach13 and welcome to the community!
Can you share the calculation process with the community? Preferably with screenshots if you can.
Thank you for the quick feedback,
Not after I added the choose multiple
Can you explain this a little further?
okay let me try and make it simple…
How can i include a sum at the end of the form depending on SPECIES CAUGHT?
Hi @zachzach13
If DID YOU CATCH FISH TODAY?
question has been answered YES
, your SUM note
displays NaN
That is because In the ODK Form Logic, unanswered number questions are nil. That is, they have no value. When a variable referencing an empty value is used in a math operator or function, it is treated as Not a Number (NaN
). The empty value will not be converted to zero. The result of a calculation including NaN
will also be NaN
, which may not be the behavior you want or expect.
To convert empty values to zero, you can use either the coalesce()
function or the if()
function.
coalesce(${potentially_empty_value}, 0)
if(${potentially_empty_value}=“”, 0, ${potentially_empty_value})
In your case, you have possible unanswered integer
questions depending on your multiple choice
question.
So changing your calculate
Total_Weight
question to:
coalesce(${NPW}, 0)+coalesce(${DW}+...
would solve your issue.
Wow, thanks a bunch. let me read more about it and make the edits.
Works like a charm. I appreciate you brother. Thank you.
I have just thought of a different scenario. What would I do 8n the same case if the species were very many. Like 300 marine species?