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
kjunkjun 

need a formula that would select a value from a picklist from a set of numbers

I'm trying to create a formula that would do the following: 

Card_Number__c (text field) contains credit card numbers and depending on the prefix number entered, will determine the Card_Type__c from a picklist with the values of Visa, MasterCard, AMEX, Discover

If the Card Type's Card Number Prefix starts with the following, will determine the value for the Card_Type__c

Card Type:                    Card Number Prefix
American Express              34 and 37
MasterCard.                   51,52,53,54,55
Visa                          4
Discover                      300, 309, 352, 36, 38, 39, 64, 65, 601, 622, 624, 628
 

Is this possible with a formula? 

 

Best Answer chosen by kjun
David Zhu 🔥David Zhu 🔥
You may use th following fumula:
 
IF(BEGINS( Other_Business_Sector__c,'4'),'VISA',
  IF(
      OR(BEGINS( Other_Business_Sector__c,'34'),
         BEGINS( Other_Business_Sector__c,'37')),'AMEX',

    IF(
      OR(BEGINS( Other_Business_Sector__c,'51'),
         BEGINS( Other_Business_Sector__c,'52'),
         BEGINS( Other_Business_Sector__c,'53'),
         BEGINS( Other_Business_Sector__c,'54'),
         BEGINS( Other_Business_Sector__c,'55')),'MASTER CARD',

    IF(
      OR(BEGINS( Other_Business_Sector__c,'300'),
         BEGINS( Other_Business_Sector__c,'309'),
         BEGINS( Other_Business_Sector__c,'352'),
         BEGINS( Other_Business_Sector__c,'36'),
         BEGINS( Other_Business_Sector__c,'38'),
         BEGINS( Other_Business_Sector__c,'39'),
         BEGINS( Other_Business_Sector__c,'64'),
         BEGINS( Other_Business_Sector__c,'65'),
         BEGINS( Other_Business_Sector__c,'601'),
         BEGINS( Other_Business_Sector__c,'622'),
         BEGINS( Other_Business_Sector__c,'628')),'DISCOVERY','')
     )
  )
)

 

All Answers

David Zhu 🔥David Zhu 🔥
You may use th following fumula:
 
IF(BEGINS( Other_Business_Sector__c,'4'),'VISA',
  IF(
      OR(BEGINS( Other_Business_Sector__c,'34'),
         BEGINS( Other_Business_Sector__c,'37')),'AMEX',

    IF(
      OR(BEGINS( Other_Business_Sector__c,'51'),
         BEGINS( Other_Business_Sector__c,'52'),
         BEGINS( Other_Business_Sector__c,'53'),
         BEGINS( Other_Business_Sector__c,'54'),
         BEGINS( Other_Business_Sector__c,'55')),'MASTER CARD',

    IF(
      OR(BEGINS( Other_Business_Sector__c,'300'),
         BEGINS( Other_Business_Sector__c,'309'),
         BEGINS( Other_Business_Sector__c,'352'),
         BEGINS( Other_Business_Sector__c,'36'),
         BEGINS( Other_Business_Sector__c,'38'),
         BEGINS( Other_Business_Sector__c,'39'),
         BEGINS( Other_Business_Sector__c,'64'),
         BEGINS( Other_Business_Sector__c,'65'),
         BEGINS( Other_Business_Sector__c,'601'),
         BEGINS( Other_Business_Sector__c,'622'),
         BEGINS( Other_Business_Sector__c,'628')),'DISCOVERY','')
     )
  )
)

 
This was selected as the best answer
kjunkjun
 Thank you!
Somesh wtSomesh wt
hey thanks for this I was looking to checkout for my site Wisetrolley (https://wisetrolley.com/)for the same query.