Post

2 followers Follow
0
Avatar

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?

Henrik Arvedsen

Please sign in to leave a comment.

3 comments

0
Avatar

Hi Henrik,

do you get the error "Number is not a function"? If so, remove the brackets ().
You also get an error if var two = 0; JavaScript can't divide by 0. 

Rainer 

Rainer Grabowski 0 votes
0
Avatar

Hi Rainer,
I have tried without brackets as well.

The error I get is in Danish but translated is:
The result is not a whole number.

Henrik Arvedsen 0 votes
0
Avatar

Hi Henrik,

I assume the correct translation is: Is not a valid number :) 
Can you please share a screenshot of your calculation field which shows the code and the error message?
Open an item, click "Tilpas skabelon", click into the calc field and make a screenshot. 

Rainer

Rainer Grabowski 0 votes