0

I am new in coding and I am trying to learn formulas.

For the below formula:

IF
(
AND
(IsInfected__c==TRUE, Is_Patient_Dead__c==TRUE),
Min_Pay__c*0, Max_Pay__c,   

IF(
AND(IsInfected__c==TRUE, IsCured__c==TRUE)
,Max_Pay__c,Min_Pay__c))

I get following Error:

Incorrect number of parameters for function 'IF()'. Expected 3, received 4. If I add one more parentheses, it shows me another error ' Syntax error. Extra ')'

2 Answers 2

0

please re - phrase the formula

IF((IsInfected__c==TRUE && Is_Patient_Dead__c==TRUE),0,IF((IsInfected__c==TRUE && IsCured__c==TRUE),Max_Pay__c,Min_Pay__c))

above formula will achieve the below use cases:

use case 1 : if patient is infected and dead, no payment

use case 2 : if patient is infected and cured, either pay maximum or minimum based on the treatment.

hope this helps

2
  • Yeah Shivaraman, I got the answer. I also removed Max_Pay__c from my first condition and achieved what I wanted. Commented May 15, 2020 at 20:33
  • There is never a need to compare a Boolean value to TRUE. You can just use the name of the Boolean value.
    – David Reed
    Commented May 23, 2020 at 14:22
2

If statements require three parameters, the condition, the value if true, then the value if false. You have four parameters.

  1. AND(IsInfected__c==TRUE, Is_Patient_Dead__c==TRUE)
  2. Min_Pay__c*0
  3. Max_Pay__c
  4. IF( AND(IsInfected__c==TRUE, IsCured__c==TRUE) ,Max_Pay__c,Min_Pay__c)

I'm not sure what you meant to do, but you have an extra value you need to get rid of.

Also, a Boolean value is already a Boolean value, so you can simply say:

  • IsInfected__c
  • IsCured__c

Rather than comparing the value to TRUE.

1
  • I am just trying to do if Patient is infected and if he is dead, then he should not pay anything, if patient is infected and he is cured then he should max pay. I removed "True" from the boolean, but is giving me same error. Commented May 15, 2020 at 19:13

You must log in to answer this question.

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