+ Start a Discussion
Satish Kumar OsuriSatish Kumar Osuri 

Need Formula optimization

I have 2 fields Source_System__c (Picklist) and  Currency__c (Text) fields. I need to write a formula for the below condition.
I created a formula field formula_value.

if(source system == abc) && (currency == 1) then formula_value= x1
if(source system == abc) && (currency == 2) then formula_value= x2 and so on.

I wrote a formula as below which is repeating ISPICKVAL( Source_System__c, "abc"). 
 
IF((ISPICKVAL( Source_System__c, "abc")) && (Currency__c == 'Afghanistan Afghani'),"AFN",
IF((ISPICKVAL( Source_System__c, "abc")) && (Currency__c == 'Albanian Lek'),"ALL",
"NULL"))

Can anyone optimise the above formula by using picklist value only once. I need to check like this for 20 times.
Best Answer chosen by Satish Kumar Osuri
Sumitkumar_ShingaviSumitkumar_Shingavi
Hello Satish,

Try below:
IF(ISPICKVAL(Source_System__c, "abc"),
	CASE(Currency__c,
		"Afghanistan Afghani", "AFN",
		"Albanian Lek", "ALL",
		"United States", "USD",
        //You can add more conditions here
		"None"), 
	"NULL"
)

Hope this helps! if yes, then mark it as solution.
 

All Answers

Sumitkumar_ShingaviSumitkumar_Shingavi
Hello Satish,

Try below:
IF(ISPICKVAL(Source_System__c, "abc"),
	CASE(Currency__c,
		"Afghanistan Afghani", "AFN",
		"Albanian Lek", "ALL",
		"United States", "USD",
        //You can add more conditions here
		"None"), 
	"NULL"
)

Hope this helps! if yes, then mark it as solution.
 
This was selected as the best answer
Satish Kumar OsuriSatish Kumar Osuri
Hi Sumit, Thanks for the quick turn around. It is working fine.