# If formula to return either the lead company name or contact on a related object

Good Afternoon All,

I need some help with a formula.

Aim – Create a text formula which returns either the Lead company name or the contact company name based on criteria.

Criteria – If the lead isn’t converted then return the lead company name; if the lead is converted then return the contact account name.

Fields to use are ;

Really hoping you lovely people can help

• What formulas have you tried and what were the issues you ran into? Commented Jul 2, 2015 at 15:44
• I tried the following formula, but that returns either lead company name or the contact account name. I havent however included any if statements and this is where i am struggling BrightTALK__Lead__r.Company+ " " +BrightTALK__Contact__r.Account.Name Commented Jul 2, 2015 at 15:50

IsConverted is a checkbox field values will be true or false, so you should be able to write it like this:

``````IF(IsConverted, BrightTALK__Contact__r.Account.Name, BrightTALK__Lead__r.Company)
``````

Try this: `BLANKVALUE(BrightTALK__Contact__r.Account.Name, BrightTALK__Lead__r.Company)`

Based on comments try a combination:

``````IF(IsConverted, BLANKVALUE(BrightTALK__Contact__r.Account.Name, BrightTALK__Lead__r.Company), BrightTALK__Lead__r.Company)
``````

Looks like this last formula will work:

``````IF(ISBLANK( BrightTALK__Lead__c) || BrightTALK__Lead__r.IsConverted, BrightTALK__Contact__r.Account.Name,BrightTALK__Lead__r.Company)
``````

BLANKVALUE Determines if an expression has a value and returns a substitute expression if it does not. If the expression has a value, returns the value of the expression.

• Hi Jenny B , Thanks for your response, however its only returning Lead company name. If this was an excel formula it would be something along the lines of =IF(ISBLANK(B2),A2,B2) Commented Jul 2, 2015 at 16:20
• @DMason updated with another option. Commented Jul 2, 2015 at 16:22
• HI Jenny, that works but what happens when you convert a lead ? Which name does it take ? for eg is it the lead company name or the account.name ? Commented Jul 2, 2015 at 16:23
• @DMason it will always use the first field when it's not blank, when it is blank it will use the second value. Commented Jul 2, 2015 at 16:24
• No worries, tweeted you aswell :) thank you Jenny. Commented Jul 3, 2015 at 13:29