You need to have a good understand of formulas for this to work. Specifically, IF()
, BEGINS()
, RIGHT()
, LEFT()
, TRIM()
, FIND()
, and CONTAINS()
.
The following should be able to set your Vertical__c
. It will check the Category__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.
IF(
BEGINS(
RIGHT(Category__c, 1), ","
)
&&
!CONTAINS(
RIGHT(Category__c, 0), ","
),
TRIM(RIGHT(Category__c, 0))
)
IF(
BEGINS(
RIGHT(Category__c, 2), ","
)
&&
!CONTAINS(
RIGHT(Category__c, 1), ","
),
TRIM(RIGHT(Category__c, 1))
)
IF(
BEGINS(
RIGHT(Category__c, 3), ","
)
&&
!CONTAINS(
RIGHT(Category__c, 2), ","
),
TRIM(RIGHT(Category__c, 2))
)
IF(
BEGINS(
RIGHT(Category__c, 4), ","
)
&&
!CONTAINS(
RIGHT(Category__c, 3), ","
),
TRIM(RIGHT(Category__c, 3))
)
IF(
BEGINS(
RIGHT(Category__c, 5), ","
)
&&
!CONTAINS(
RIGHT(Category__c, 4), ","
),
TRIM(RIGHT(Category__c, 4))
)
IF(
BEGINS(
RIGHT(Category__c, 6), ","
)
&&
!CONTAINS(
RIGHT(Category__c, 5), ","
),
TRIM(RIGHT(Category__c, 5))
)
IF(
BEGINS(
RIGHT(Category__c, 7), ","
)
&&
!CONTAINS(
RIGHT(Category__c, 6), ","
),
TRIM(RIGHT(Category__c, 6))
)
IF(
BEGINS(
RIGHT(Category__c, 8), ","
)
&&
!CONTAINS(
RIGHT(Category__c, 7), ","
),
TRIM(RIGHT(Category__c, 7))
)
IF(
BEGINS(
RIGHT(Category__c, 9), ","
)
&&
!CONTAINS(
RIGHT(Category__c, 8), ","
),
TRIM(RIGHT(Category__c, 8))
)
IF(
BEGINS(
RIGHT(Category__c, 10), ","
)
&&
!CONTAINS(
RIGHT(Category__c, 9), ","
),
TRIM(RIGHT(Category__c, 9))
)
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 in Vertical__c
to ensure it can still be used in this formula.
LEFT(
Category__c,
FIND(", " + Vertical__c, Category__c)
)
This will take all characters to the left of the Vertical__c
in Category__c
. Note that the ", " is prepended to the beginning of the Vertical__c
to ensure they are removed from the Event_Type__c
.
Note: I have not been able to test this myself, but this should give you a good starting point. Good luck!
substringBeforeLast(String)
,substringAfterLast(String)
, etc