Arithmetic calculations

0
com.mendix.modules.microflowengine.MicroflowException: Failed to evaluate expression, error occurred on line 1, character 2 ($Variable A div $variable B)*100   Hi all i have a requirement like we have decimal values in a list where i have to use logic like above one  In detail i have entity where var-1 and var-2 are the Decimal attributes  and requirement like i have a formula like FinalA =( $var-1 div $var-2)*100 here i am getting var-1 as 13.03 and var-2 is 0 but i am getting the error like in( An error has occurred while handling the request. [User 'MxAdmin' with session id '328a1880-XXXX-XXXX-XXXX-XXXXXXXXc39b' and roles 'Administrator'] after it shows com.mendix.modules.microflowengine.MicroflowException: Failed to evaluate expression, error occurred on line 1, character 2 ($Variable A div $variable B)*100   could you please help me out how give a empty check or how to slve this problem       
asked
2 answers
0

Hi Anjineyulu,

that would become something like:

if $Variable A != 0 and $variable B != 0
   then ($Variable A div $variable B)*100
else 0

 

answered
0

As you know, it’s impossible to divide by 0, so to account for this you can do something like this…

 

if ($VariableB != 0) then
 ($VariableA div $VariableB)*100
else
 0


In this example I return 0 if $VariableB is zero, but you will need to work out what your answer should be in this case.

I hope this helps. 

answered