Hello @kna1337
I’m sorry, but your equation includes many parser errors.
You have two alternatives: you can nest the IF
operations, or you can use if
conditional statements and the equation with function
structure.
By nesting the IF
operations, the equations would be similar to:
PREC(
IF(AND(fieldname5>=50, fieldname5<=150, fieldname6 == 'name55'),
fieldname1*147.3*fieldname5,
IF(AND(fieldname5>=151, fieldname5<=300, fieldname6 == 'name56'),
fieldname1*86.6*fieldname5,
IF(AND(fieldname5>=301, fieldname5<=500, fieldname6 == 'name57'),
fieldname1*59.8*fieldname5,
0))),
2)
Using if
conditional statements and function
structure:
PREC((function(){
if(AND(fieldname5>=50, fieldname5<=150, fieldname6 == 'name55'))
return fieldname1*147.3*fieldname5;
if(AND(fieldname5>=151, fieldname5<=300, fieldname6 == 'name56'))
return fieldname1*86.6*fieldname5;
if(AND(fieldname5>=301, fieldname5<=500, fieldname6 == 'name57'))
return fieldname1*59.8*fieldname5;
return 0;
})(), 2)
Both equations are equivalent, but I prefer the second variant because it is easy to understand.
Best regards.