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

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)
)
| improve this answer | |
  • Thank you! I appreciate the help! – Stefanie Nepaul Jul 2 '19 at 20:01
  • @StefanieNepaul You're welcome! – sfdcfox Jul 2 '19 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.