Text Formula String Concatenation - Omit Trailing Comma
@AdrianLarson I used your suggestion for a similar solution and it worked for a year or so, until I was asked to include more Checkboxes (12 in all) in the formula, then I got:
Error: Compiled formula is too big to execute (5,713 characters). Maximum size is 5,000 characters.
I found a simpler solution. Include the ", " in each result, then add a period to the end of your IF statements. Wrap the code with SUBSTITUTE
to replace ", ." with null in order to remove the trailing comma at the end of your text
SUBSTITUTE(
IF( Sunday__c, 'Sunday, ','') &
IF( Monday__c, 'Monday, ','') &
IF( Tuesday__c, 'Tuesday, ','') &
IF( Wednesday__c, 'Wednesday, ','') &
IF( Thursday__c, 'Thursday, ','') &
IF( Friday__c, 'Friday, ','') &
IF( Saturday__c, 'Saturday, ','') &
'.'),
', .', NULL)
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 useCheckbox__c
. - The proper string concatenation operator is a single ampersand (
&
).