if(,,) function in calculation field

68 views
Skip to first unread message

Craig

unread,
Dec 31, 2017, 10:34:56 AM12/31/17
to mementodatabase
I wonder whether this is a bug or intentional. In a calculation field, All the arguments of the if(,,) function are evaluated.
I would like to use the if(,,) function in a calculation field to avoid dividing by zero.
For example:
if(#{fieldA}!=0,#{(fieldB}/#{fieldA}*100)+'%','')

However, this does not avoid the divide by zero error because all of the arguments to the if function are evaluated.
I could change it to a Javascript field, but I prefer the simplicity of the calculation fields.
A work-around involves nested if functions: (the interior if forces the denominator to be 1 in the unused branch of the exterior if)

if(#{fieldA}!=0,#{(fieldB}/if(#{fieldA}==0,1,#{fieldA})*100)+'%','')
But this added complexity makes me want to give up and use Javascript for this field.

Reply all
Reply to author
Forward
0 new messages