Calculation can't divide two variables
Hi,
I have two category fields with one selection each.
In a calculation field I need to get those variables and divide them to get the percentage.
The code for getting the variables is working fine:
var one = Number (@Category one)
var two = Number (@Category two)
But this does not work:
(one / two) * 100
None of the variables are null.
+,  and * does work though.
What am I doing wrong when dividing?

You can try
var a = Number(@field A)  0;
var b = Number(@field B)  0;
(a/b)  0.
But : if b = 0 it doesn't give you a valid result because JavaScript can't divide by 0. So var b should be Number(@field B)  1;
If one of the fields is a number field you don't need Number(@field)  0; you can use @field  0 (or 1)
 1 means = if this field is empty use the value 1.
Please sign in to leave a comment.
Comments
6 comments