Concatenate fields in a view with comma when values may be empty One can easily concatenate fields in views with a re-write rule.. However, I have two fields, age_range and warning, the second of which may be empty. I want to display them like this:

Ages 2+
Ages 4-10, choking hazard

If warning is empty, I don't want to show a comma. If I make a rewrite rule like this
[age_range], [warning]

Then I get a result like this:

Ages 2+,
Ages 4-10, choking hazard

How can I avoid a trailing comma?
I would actually suggest doing the reverse of the answered question that you linked to for just the scenario you are describing.


Add Field B and Exclude it from the display.
In the Rewrite results area of Field B, enable Rewrite the output of this field. 
On Field B, add a comma and the token for the raw value: ', [field-b]'
Under 'No Results Behavior' for Field B, make sure that 'Hide if empty' and 'Hide rewriting if empty' are checked.
Then rewrite your Field A to include Field B: '[field-a][field-b]'. Make sure there is no space, so that the comma will immediately follow Field A if Field B has a value.