function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nish321Nish321 

Multiple IF conditions in formula field

I'm writing a single formula field that should be the combination of all the following:

IF(Days_before_Ren__c >0, (IMAGE("/resource/1438712699000/GreenBall", "GreenBall")),
 
IF(Days_Until_Expiration__c<=0,(IMAGE("/resource/1440024261000/Blackball", "Blackball")),

IF(Days_before_Ren__c <=0, (IMAGE("/resource/1438712582000/RedBall", "RedBall")))))


Please help me out with the syntax.
Best Answer chosen by Nish321
William TranWilliam Tran
Okay, 

try this, you are missing the default if none of the conditions are true.
 
IF(MailingLatitude<0, IMAGE("/resource/1438712699000/GreenBall.jpeg", "GreenBall"),
IF(MailingLatitude<=0,IMAGE("/resource/1440024261000/Blackball.jpeg", "Blackball"),
IF(MailingLatitude<=0, IMAGE("/resource/1438712582000/RedBall.jpeg", "RedBall"),""
)))

This is shorter and provide the same result:
IF(MailingLatitude<0, IMAGE("/resource/1438712699000/GreenBall.jpeg", "GreenBall"),
IF(MailingLatitude<=0,IMAGE("/resource/1440024261000/Blackball.jpeg", "Blackball"),
IMAGE("/resource/1438712582000/RedBall.jpeg", "RedBall")
))

Thx
 

All Answers

William TranWilliam Tran
What error did you get?

Most image files have an extension like .gif or .jpeg

try this if your files are .gif:
 
IF(Days_before_Ren__c >0, IMAGE("/resource/1438712699000/GreenBall.gif", "GreenBall"),
IF(Days_Until_Expiration__c<=0,IMAGE("/resource/1440024261000/Blackball.gif", "Blackball"),
IF(Days_before_Ren__c <=0, IMAGE("/resource/1438712582000/RedBall.gif", "RedBall")
)))
As a common practice, if your question is answered, please choose 1 best answer. 
But you can give every answer a thumb up if that answer is helpful to you. 

Thanks
 
Nish321Nish321
Hi William,

It's still throwing the error : Incorrect number of parameters for function 'IF()'. Expected 3, received 2 (Related field: Formula)
 
IF(Days_before_Ren__c >0, IMAGE("/resource/1438712699000/GreenBall.jpeg", "GreenBall"),
IF(Days_Until_Expiration__c<=0,IMAGE("/resource/1440024261000/Blackball.jpeg", "Blackball"),
IF(Days_before_Ren__c <=0, IMAGE("/resource/1438712582000/RedBall.jpeg", "RedBall")
)))

 
William TranWilliam Tran
Okay, 

try this, you are missing the default if none of the conditions are true.
 
IF(MailingLatitude<0, IMAGE("/resource/1438712699000/GreenBall.jpeg", "GreenBall"),
IF(MailingLatitude<=0,IMAGE("/resource/1440024261000/Blackball.jpeg", "Blackball"),
IF(MailingLatitude<=0, IMAGE("/resource/1438712582000/RedBall.jpeg", "RedBall"),""
)))

This is shorter and provide the same result:
IF(MailingLatitude<0, IMAGE("/resource/1438712699000/GreenBall.jpeg", "GreenBall"),
IF(MailingLatitude<=0,IMAGE("/resource/1440024261000/Blackball.jpeg", "Blackball"),
IMAGE("/resource/1438712582000/RedBall.jpeg", "RedBall")
))

Thx
 
This was selected as the best answer
Vipul TaylorVipul Taylor
The last IF statement does not havee an else clause and hence the error. I have updated the formula to include that.
 
IF(Days_before_Ren__c >0, IMAGE("/resource/1438712699000/GreenBall.jpeg", "GreenBall"),
IF(Days_Until_Expiration__c<=0,IMAGE("/resource/1440024261000/Blackball.jpeg", "Blackball"),
IF(Days_before_Ren__c <=0, IMAGE("/resource/1438712582000/RedBall.jpeg", "RedBall"),"SOMETHING"
)))

Vipul
Nish321Nish321
Thank you @William and @Vipul