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
HNT_NeoHNT_Neo 

Multiple Values with final value


I have this scenario:
abc_c,(A)+ def_c,(West)  + ghi_c,(Elite) = xyz_c, (90,000)
abc_c,(B)+ def_c,(MidWest) + ghi_c,(Preferred) = xyz_c, (50,000)


Values in the () are values from a picklist. The custom api fields are picklists which contains various values. Whenever any of these combinations are selected, the final value should be the set value, e.g., 90,000.


What would be the correct syntax to write this up, thanks in advance!

Best Answer chosen by HNT_Neo
Anupama SamantroyAnupama Samantroy
IF(
AND(ISPICKVAL(Market__c, 'A'), ISPICKVAL(Auto_Region_F__c, 'Midwest'),  ISPICKVAL(Current_Tier__c, 'Elite Preferred')),90000,
IF(AND(ISPICKVAL(Market__c, 'B'), ISPICKVAL(Auto_Region_F__c, 'Midwest'),  ISPICKVAL(Current_Tier__c, 'Elite Preferred')),45000,0))

If the formula field is of text type then put the numbers in quotes please.

Thanks
Anupama

All Answers

Anupama SamantroyAnupama Samantroy
Hi,
if(abc__c=='A' && def__c='West' && ghi__c ='Elite'){
   xyz__c = 90000; //if xyz is number else put that also in quotes
}else if(abc__c=='B' && def__c='MidWest' && ghi__c ='Prefered'){
   xyz__c = 50000;
}
Thanks
Anupama
 
HNT_NeoHNT_Neo
I receive an error when I enter the following: 
IF( 
Market__c=='A' && Auto_Region_F__c =='Midwest' && Current_Tier__c=='Elite Preferred')
{Elite_Preferred_CY_Reside_Volume__c='90000';} else 
IF(
Market__c=='B' && Auto_Region_F__c =='Midwest' && Current_Tier__c=='Elite Preferred')
{Elite_Preferred_CY_Reside_Volume__c='45000';}

 
HNT_NeoHNT_Neo
syntax error
HNT_NeoHNT_Neo
By the way, this is a formula being used with in the custom field not in apex
HNT_NeoHNT_Neo
User-added image
Anupama SamantroyAnupama Samantroy
IF(
AND(ISPICKVAL(Market__c, 'A'), ISPICKVAL(Auto_Region_F__c, 'Midwest'),  ISPICKVAL(Current_Tier__c, 'Elite Preferred')),90000,
IF(AND(ISPICKVAL(Market__c, 'B'), ISPICKVAL(Auto_Region_F__c, 'Midwest'),  ISPICKVAL(Current_Tier__c, 'Elite Preferred')),45000,0))

If the formula field is of text type then put the numbers in quotes please.

Thanks
Anupama
This was selected as the best answer
HNT_NeoHNT_Neo


Thank you Anupama! 


I shall also work on creating an Apex Class from what you provided as well. 

Much appreciated!

Anupama SamantroyAnupama Samantroy
Happy to help !
HNT_NeoHNT_Neo

Anupama, quick question, 

What if "Current_Tier__c" is not a picklist field, but a text field, how would that the syntax be re-written with the same choice of 'Elite Preferred'?

Thanks!

IF(
AND(
ISPICKVAL(Market__c, 'A'), 
ISPICKVAL(Auto_Region_F__c, 'Midwest'),  
ISPICKVAL(Current_Tier__c, 'Elite Preferred')),90000,
IF(
AND(
ISPICKVAL(Market__c, 'B'), 
ISPICKVAL(Auto_Region_F__c, 'Midwest'),  
ISPICKVAL(Current_Tier__c, 'Elite Preferred')),45000,0
))
HNT_NeoHNT_Neo
Actually figured it out. Thanks anyways!