Omitting Blank Lines when Joining Strings

:bullseye: What is your goal?

Hi all,

I’ve been tearing my hair out with this one and can’t seem to work out the solution!

I am joining mutiple strings and separating them by a new line which works well. However, some of those string might be empty and I want to omit that blank line completely from the output.

It’s a minor niggle, but any help would be really appreciated!

:thinking: What is the problem & what have you tried?

The Make AI suggested a couple of things but I couldn’t get those to work either.

The value I am using to join the strings is:

{{join(add(emptyarray; 3.mappable_column_values.address_15.text; 3.mappable_column_values.address_25.text; 3.mappable_column_values.address_33.text; 3.mappable_column_values.address_48.text; 3.mappable_column_values.town_city7.text; 3.mappable_column_values.postcode2.text); newline)}}

The output from this is for example (where 1st and 4th line are empty):

23
New Street

City
Postcode

I would like that output to be:
23
New Street
City
Postcode

If Address_15, Address_25 and Address_33 are empty I want those lines to be removed completely, so the output string starts with Address_48.

Similarly, if Address_25 and Address_48 exist but Address_33 doesn’t, I don’t want to see an empty line between the two in the output.

Hey there,

wrap the add() function in a remove() function and have it remove {{null}} values.

2 Likes

Thankyou so much! I had tried using the remove function but had used emptystring rather than null - that’s where I went wrong.

1 Like

If in doubt, you can always have more than one value to remove in the remove function. This should remove all the missing, whitespace, and null values:

{{ remove(array; null; emptystring; space; tab; newline; carriagereturn) }}
:warning: Make Input Markup:
        Copy-paste the above into the field, including start/end curly brackets for it to import as intended

1 Like