You need to sign in to do that
Don't have an account?

How to get last index of something in formula field
for example I have this string LONG-08080-aSDDdd-001
how do I get the end of the string after the last "-" : note that 001 could also be 00000001, 0100000 etc.. so not only 3 chars long
I think you may need to use a FIND function, I don't have any examples handy, but there's one in the Formulas Guide Book posted in the online Learning Center
Hi lodoss1118,
I am facing the same issue.
Did you figure out a solution to retrieve the last index ?
Thanks,
Simply replace myCustomField__c in the formula below with whatever field you want to return the last index. NOTE: only works on fields with 3 segments. NOTE: if you using some other separator besides underscore change out those 3 references as well.
TRIM(RIGHT(TRIM(RIGHT(myCustomField__c,LEN(myCustomField__c)-
FIND("_",myCustomField__c))),LEN(TRIM(RIGHT(myCustomField__c,LEN(myCustomField__c)-
FIND("_",myCustomField__c))))-FIND("_",TRIM(RIGHT(myCustomField__c,LEN(myCustomField__c)-
FIND("_",myCustomField__c))))))
My attempt to explain what is happening;
The base formula which will return everything after an underscore is
TRIM(RIGHT(myCustomField__c,LEN(myCustomField__c)-FIND("_",myCustomField__c)))
Since we want everything after the second underscore we replace all 3 occurences of the the custom field in the base formula with the formula itself. Each occurrence of the base formula, which references the custom field, will return everything after the first underscore e.g. mySegment2_mySegment3. The enclosing formula will then find everything after the first underscore of the mySegment1_mySegment2 string, which will be the third or last segment of the original string i.e. mySegment3.
REVERSE(LEFT(REVERSE("your_field_or_string"), FIND("your_char_to_find", REVERSE("your_field_or_string"))-1))
Example: LONG-08080-aSDDdd-001
reverse("LONG-08080-aSDDdd-001") = "100-ddDDSa-08080-GNOL"
find("-", "100-ddDDSa-08080-GNOL") = 4
left("100-ddDDSa-08080-GNOL", 4-1 (to remove the "-") = "100"
reverse("100") = "001"