Error: Incorrect number of parameters for function 'IF()'. Expected 3, received 1 - Answers - Salesforce Trailblazer Community
Ask Search:
Angela Mullen-SmithAngela Mullen-Smith 

Error: Incorrect number of parameters for function 'IF()'. Expected 3, received 1

I have created a formula field to display a flag if there has been no activity on an account for 7 years.
It works well and the Flag is displayed against an account.

IMAGE (
IF(
( Yrs_since_last_Activity__c < 7),"/img/samples/flag_green.gif",
"/img/samples/flag_red.gif" ),
"Account Health" )

I now need to add a new condition - If the Account is a business Account and the last activity on  Account is over 7 yrs it shuld be flagged Red, and Green if it is under 7 yrs.
Likewise if it is a Person Account has no activity for 3+ years it should be flagged red and green if there has been activity in the past 3 years.

I do not know what I am doing wrong

IMAGE (
IF( 
AND( 
RecordTypeId = "012b0000000LSbhAAG",
Yrs_since_last_Activity__c < 7)
),
 "/img/samples/flag_green.gif",
IF(
AND(RecordTypeId = "012b0000000LSbhAAG",
Yrs_since_last_Activity__c > 7)
),
"/img/samples/flag_red.gif",
IF(
AND(
RecordTypeId = "0120N000000F7h8QAC",
Yrs_since_last_Activity__c < 3)
),
"/img/samples/flag_green.gif",
IF(
AND(
RecordTypeId = "0120N000000F7h8QAC",
Yrs_since_last_Activity__c > 3)
),
"/img/samples/flag_red.gif",

"Account Health")
Best Answer chosen by Angela Mullen-Smith
Ahilesh RagavanAhilesh Ragavan
Using IDs like this:
IMAGE(
CASE(RecordTypeId,
"012b0000000LSbh",IF(Yrs_since_last_Activity__c < 7,"/img/samples/flag_green.gif","/img/samples/flag_red.gif" ),
"0120N000000F7h8",IF(Yrs_since_last_Activity__c < 3,"/img/samples/flag_green.gif","/img/samples/flag_red.gif" ),
NULL),"Account Health"
)

Formula fields doesn't work with 18 digit IDs.

All Answers

Tony TrinhTony Trinh
Hi Angela,

Try this:
IMAGE(
IF( 
AND( 
  RecordTypeId = "012b0000000LSbhAAG",
  Yrs_since_last_Activity__c < 7
),
 "/img/samples/flag_green.gif",
IF(
AND(
  RecordTypeId = "012b0000000LSbhAAG",
  Yrs_since_last_Activity__c > 7
),
"/img/samples/flag_red.gif",
IF(
AND(
  RecordTypeId = "0120N000000F7h8QAC",
  Yrs_since_last_Activity__c < 3
),
"/img/samples/flag_green.gif",
IF(
AND(
  RecordTypeId = "0120N000000F7h8QAC",
  Yrs_since_last_Activity__c > 3
),
"/img/samples/flag_red.gif",

"Account Health")))))

 
Ahilesh RagavanAhilesh Ragavan
Using IDs like this:
IMAGE(
CASE(RecordTypeId,
"012b0000000LSbh",IF(Yrs_since_last_Activity__c < 7,"/img/samples/flag_green.gif","/img/samples/flag_red.gif" ),
"0120N000000F7h8",IF(Yrs_since_last_Activity__c < 3,"/img/samples/flag_green.gif","/img/samples/flag_red.gif" ),
NULL),"Account Health"
)

Formula fields doesn't work with 18 digit IDs.
This was selected as the best answer
Tony TrinhTony Trinh
++Ahilesh, you're right about the 15 digit IDs. Need to drop the last 3 characters on each ID.
Angela Mullen-SmithAngela Mullen-Smith
arrrrrrrrrrrrrrgh ... I hate those error messages 

Thanks Guys I really appreciate your help.

I did not realise that you could put an IF ststement inside a Case statement