I think you should take a look at Salesforce's Formula Operators and Functions, and especially at the text Functions. I am not even sure it will be possible in you case but you can try it anyways:
FIND: Returns the position of a string within a string of text represented
as a number.
LEFT: Returns the specified number of characters from the beginning of a
text string.
RIGHT: Returns the specified number of characters from the beginning of a
text string.
The only formula i can imagine for your case compares the trimmed and untrimmed name string to get the number of the words in the whole string. And then search for the last blank. Unfortunately we can't create a full dynamic formula (i can't find a way to search the string from the right side), in my example this will work with up to 7 words in the name string (you can try to expand this formula):
First_Name__c & ' ' & LEFT(Last_Name__c, FIND(" ", Last_Name__c)) & ' ' &
CASE( LEN(Last_Name__c) - LEN(SUBSTITUTE(Last_Name__c,' ', '')),
1, RIGHT(Last_Name__c, LEN(Last_Name__c) - FIND(" ", Last_Name__c)),
2, RIGHT(Last_Name__c, LEN(Last_Name__c) - FIND(" ", Last_Name__c, FIND(" ", Last_Name__c)+1)),
3, RIGHT(Last_Name__c, LEN(Last_Name__c) - FIND(" ", Last_Name__c, FIND(" ", Last_Name__c, FIND(" ", Last_Name__c)+1)+1) ),
4, RIGHT(Last_Name__c, LEN(Last_Name__c) - FIND(" ", Last_Name__c, FIND(" ", Last_Name__c, FIND(" ", Last_Name__c, FIND(" ", Last_Name__c)+1)+1)+1) ),
5, RIGHT(Last_Name__c, LEN(Last_Name__c) - FIND(" ", Last_Name__c, FIND(" ", Last_Name__c, FIND(" ", Last_Name__c, FIND(" ", Last_Name__c, FIND(" ", Last_Name__c)+1)+1)+1)+1) ),
6, RIGHT(Last_Name__c, LEN(Last_Name__c) - FIND(" ", Last_Name__c, FIND(" ", Last_Name__c, FIND(" ", Last_Name__c, FIND(" ", Last_Name__c, FIND(" ", Last_Name__c, FIND(" ", Last_Name__c)+1)+1)+1)+1)+1) ),
Last_Name__c
)
This is the result:

I think this is how far you have to go to implement formula here. I'm doubtful its compile size will be under the limit, but I haven't checked.
IF(Sunday__c, 'Sunday' & IF(
OR(Monday__c, Tuesday__c, Wednesday__c, Thursday__c, Friday__c, Saturday__c), ',', ''
), '') &
IF(Monday__c, 'Monday' & IF(
OR(Tuesday__c, Wednesday__c, Thursday__c, Friday__c, Saturday__c), ',', ''
), '') &
IF(Tuesday__c, 'Tuesday' & IF(
OR(Wednesday__c, Thursday__c, Friday__c, Saturday__c), ',', ''
), '') &
IF(Wednesday__c, 'Wednesday' & IF(
OR(Thursday__c, Friday__c, Saturday__c), ',', ''
), '') &
IF(Thursday__c, 'Thursday' & IF(
OR(Friday__c, Saturday__c), ',', ''
), '') &
IF(Friday__c, 'Friday' & IF(Saturday__c, ',', ''), '') &
IF(Saturday__c, 'Saturday', '')
A couple notes:
- You don't need to check
Checkbox__c = true
for a checkbox in a formula. Just use Checkbox__c
.
- The proper string concatenation operator is a single ampersand (
&
).
Best Answer
You need to have a good understand of formulas for this to work. Specifically,
IF()
,BEGINS()
,RIGHT()
,LEFT()
,TRIM()
,FIND()
, andCONTAINS()
.The following should be able to set your
Vertical__c
. It will check theCategory__c
starting from the right and proceed to increment the string's length by 1 until that string begins with a ",". Once it does, it also verifies that the string does not contain any other apostraphes. If it does not, that is the last unique String in the list.You can expand this count for a bit to check more characters to the right of the end until you hit the maximum character limit of 5000. This formula is currently around 1800 characters. You should probably be able to get up to 20 characters checked easily.
You should then be able to utilize a function similar to what Michael detailed out to get the
Event_Type__c
. It is important to note that you must not utilize the full 5000 characters inVertical__c
to ensure it can still be used in this formula.This will take all characters to the left of the
Vertical__c
inCategory__c
. Note that the ", " is prepended to the beginning of theVertical__c
to ensure they are removed from theEvent_Type__c
.Note: I have not been able to test this myself, but this should give you a good starting point. Good luck!