Function for complex operation not working. Please help :)
-
Hi there,
I try to implement and logical operation in an calculated field like this:
(function(){ if(fieldname3 = 0) return prec((fieldname16/fieldname15*fieldname4)+(fieldname20/fieldname19*fieldname11),2); if(fieldname3 > 0) return prec((fieldname16/fieldname15*fieldname4)+(fieldname18/fieldname17*fieldname10)+(fieldname20/fieldname19*fieldname11),2); })();
This does not work. The basic calculation works:
prec((fieldname16/fieldname15*fieldname4)+(fieldname18/fieldname17*fieldname10)+(fieldname20/fieldname19*fieldname11),2)
But only if fieldname3 is not 0
For better understanding.
If fieldname3 is 0, the user will enter 0 in fieldname17 too. this will cause an operation “divided by zero”, which is not defined. So I need this if rule to be sure, if fieldname3 is 0, the calculation will be made without the second bracket, which is:(fieldname18/fieldname17*fieldname10)+
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Function for complex operation not working. Please help :)’ is closed to new replies.