You need to sign in to do that
Don't have an account?
Chris E
Need to shorten CASE formula that usesmultiple options with the same result
I'm trying to use a CASE field to look up the first two characters of a postcode and output some broad regions that we use to report on data. So far i have this:
CASE( UPPER(LEFT(BillingPostalCode,2)),
'PL', "South West England",
'PO', "South West England"
/*TONNES OF OTHERS */
"Unfound"
)
Obviously once i get all the UK postcodes in there, it exceeds the character limit, plus it just looks horribly clumsy. I've tried things like
'PL' : 'PO', "South West England"
to shorten the formula, but i can't seem to make any of them work. Is there any more elegant way of pointing those multiple options at a single result?
Apologies if this has been tackled elsewhere, i had a good look round the forums and couldn't find anything that seemed to solve it.
CASE( UPPER(LEFT(BillingPostalCode,2)),
'PL', "South West England",
'PO', "South West England"
/*TONNES OF OTHERS */
"Unfound"
)
Obviously once i get all the UK postcodes in there, it exceeds the character limit, plus it just looks horribly clumsy. I've tried things like
'PL' : 'PO', "South West England"
to shorten the formula, but i can't seem to make any of them work. Is there any more elegant way of pointing those multiple options at a single result?
Apologies if this has been tackled elsewhere, i had a good look round the forums and couldn't find anything that seemed to solve it.
We have encountered this issue before. Whenever there are a ton of postal codes, formula fields just don't cut it. It's also not very scalable. I would suggest creating a Custom Setting and having a trigger fill out the region field. It could look a little like this:
Custom Setting Record:
Name = 'PL'
Region__c = 'South West England'
Trigger:
This way, if you add regions, or change the name of the regions, you won't have to edit the trigger or any formula field.
Hope that helps. Good luck