I have been trying to compute percentage when using the following formula ${Section_A}div18*100 but its giving me NAN as the answer.Please support thanks

Hi @banks,

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})

2 Likes


Thanks @hakan_cetinkaya for your feedback
However when i added this to my XLS form and uploaded
that is the error i got

1 Like

Hi @banks,

You need to change “potentially empty value” with your own potentially empty values :slight_smile:

Not exactly to “potentially empty value”

1 Like

This is noted :pray: :clap:
However it seems don’t have unanswered questions in this particular calculation

Hi @banks,

If you can share your form in here, maybe community can take a look into that.

1 Like

Hi @hakan_cetinkaya
It seems am unable to upload an attachment since am a new member in the community

@banks, you should be able to upload your XLSForm to the community if you are still stuck with the issue.