0

I keep getting Error:

Incorrect number of parameters for function 'IF()'. Expected 3, received 4

Can anyone advise on where its pulling the 4?

IF ( $UserRole.Name = "x",

IF( AND (Quantity >= 2500), Discretionary_Deduct__c >= 0.02, True, 

IF( AND (Quantity >= 5000), Discretionary_Deduct__c >= 0.05, True, 

IF( AND (Quantity >= 10000), Discretionary_Deduct__c >= 0.07, True, 

IF( AND (Quantity >= 5000000), Discretionary_Deduct__c >= 0.10, True, False
)))))

1 Answer 1

2

You have your parentheses in the wrong places. The AND function should have two parameters each. The compiler is seeing IF(AND(...), ..., True, IF(...; which results in four total parameters. You also need a final else value.

IF ( $UserRole.Name = "x",

IF( AND (Quantity >= 2500, Discretionary_Deduct__c >= 0.02), True,

IF( AND (Quantity >= 5000, Discretionary_Deduct__c >= 0.05), True,

IF( AND (Quantity >= 10000, Discretionary_Deduct__c >= 0.07), True,

IF( AND (Quantity >= 5000000, Discretionary_Deduct__c >= 0.10), True, False )))))

In the more general case, you could also skip using IF statements entirely; the result of a Boolean check is already a Boolean value:

$UserRole.Name = "x" &&
(
  (Quantity >= 2500 && Discretionary_Deduct__c >= 0.02) ||
  (Quantity >= 5000 && Discretionary_Deduct__c >= 0.05) ||
  (Quantity >= 10000 && Discretionary_Deduct__c >= 0.07) ||
  (Quantity >= 5000000 && Discretionary_Deduct__c >= 0.10)
)
2
  • Thank you! I appreciate the help! Jul 2, 2019 at 20:01
  • @StefanieNepaul You're welcome!
    – sfdcfox
    Jul 2, 2019 at 20:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .