# Best way to implement a formula

I have a scenerio which is based on a field of a record. This field is a lookup relation ship to another record. Example on my `abc__c` object I have lookup to `xyz__c` object. The `xyz__c` object has a field named `type__c`. My formula is based on `xyz__c and type__c` values. The condition is:

1. If `xyz__c` is not blank
2. `type__C` has one of these `values -> 'CAR' , 'TRAIN' , 'BIKE' or 'PLANE'` If the above 2 condition satisfies then formula field should have 'FALSE' else it should have 'TRUE' text. Formula is a text type field.

This is what I got started with:

``````    IF(
OR ( ISBLANK(xyz__c),
(
UPPER(xyz__r.type__c) != 'CAR' ||
UPPER(xyz__r.type__c) != 'TRAIN' ||
UPPER(xyz__r.type__c) != 'BIKE' ||
UPPER(xyz__r.type__c) != 'PLANE'
)
)
,
'TRUE','FALSE'
)
``````

What I am know that I should be doing is putting all the combination of `type__c` in the formula field, meaning there could be case when the field has 'PLANE' instead of 'CAR' so I might have to cover all those cases in the formula field. Is that correct? Is there a better way to implement this formula field?

## 1 Answer

The formula will be as follows:

``````IF(
NOT(ISBLANK(xyz__c))
&& UPPER(xyz__r.type__c) != 'CAR'
&& UPPER(xyz__r.type__c) != 'TRAIN'
&& UPPER(xyz__r.type__c) != 'BIKE'
&& UPPER(xyz__r.type__c) != 'PLANE',
'TRUE','FALSE'
)
``````
• Thank you. There is just one condition in this that I missed. If xyz__c is blank then it should return 'TRUE'. Meaning there is no need to check the type__c field if xyz__c field values is not present. Commented May 17, 2017 at 18:28
• You can add it accordingly Commented May 17, 2017 at 18:30
• Quick question - Do you think I should be using UPPER here? Is it case sensitive here? Commented May 17, 2017 at 18:46
• UPPER is good for text comparison, if you are allowing user to enter the values Commented May 17, 2017 at 18:48
• It is case sensitive, so xyz__r.type__c == "CAR' is not same as xyz__r.type__c == 'Car' Commented May 17, 2017 at 18:54