Can an Expression Exclude Empty Columns?

Hello there. I'm new to expressions but learned much so far. I have an action that sends a pre-written email. For the email Body, I've figured out this expression to use so far:

[Address]&"

"&
[NAME]&"
"&
&[N1 PHONE 1]&"
"&
&[N1 PHONE 2]&"
"&
&[N1 PHONE 3]&"
"&
&[N1 PHONE 4]&"

"&
[NAME 2]&"
"&
&[N2 PHONE 1]&"
"&
&[N2 PHONE 2]&"
"&
&[N2 PHONE 3]&"
"&
&[N2 PHONE 4]&"

"&
[NAME 3]&"
"&
&[N3 PHONE 1]&"
"&
&[N3 PHONE 2]&"
"&
&[N3 PHONE 3]&"
"&
&[N3 PHONE 4]

However, in my data, not all PHONE columns always have a value. So, when a column is empty, it's leaving blank areas in the email. Does anyone know if there is an expression that allows me to exclude a column when it is empty? Thanks in advance! ๐Ÿ™‚

Screen Shot 2022-09-24 at 9.15.30 PM.png

Solved Solved
0 6 172
1 ACCEPTED SOLUTION

Include the line break in the conditional output.

IF(ISNOTBLANK([N1 PHONE 1]), [N1 PHONE 1] & "
", "")&IF(ISNOTBLANK([N1 PHONE 2]), [N1 PHONE 2] & "
", "")

Also, you could probably simplify using IFS instead of IF.

Finally, consider whether it would be helpful to use a technique like  Concatenate values with a delimiter: How to simula... - Google Cloud Community

View solution in original post

6 REPLIES 6

You will need to wrap EACH phone number with a conditional expression:

IF(ISNOTBLANK([N1 PHONE 1]), [N1 PHONE 1], "")

PRO TIP:  If you were to separate these into a Names table and Phone Numbers table with a Name column linking them, you could then create an email body template to handle any size list of Names and Phone Numbers.  The template would be something like this:

<<START: Names[Name ID]>>
[Name]
        <<START: {Related Phone Numbers]>>
                   [Phone Number]
       <<END>>
<<END>>

 NOTE:  this is just an example and most likely needs adjustment for your use case.  For example, filtering can be applied to limit which names and/or phone number appear.

Hi. Thank you for answering my question. I did try "ISNOTBLANK" however, it still leaves blank spaces in the email due to "" .

Tameron_0-1664121019954.png

I am still new to this so I don't quite understand what you mean by linking them and filtering them but I'll look it up! My data is linked by a Google Sheet so all of my columns and tabs are pretty much set. 

Include the line break in the conditional output.

IF(ISNOTBLANK([N1 PHONE 1]), [N1 PHONE 1] & "
", "")&IF(ISNOTBLANK([N1 PHONE 2]), [N1 PHONE 2] & "
", "")

Also, you could probably simplify using IFS instead of IF.

Finally, consider whether it would be helpful to use a technique like  Concatenate values with a delimiter: How to simula... - Google Cloud Community

YES!! Thank you so much for this!! The IF function worked!!

I tried using IFS to simplify it but I think I did something wrong as this is returning an error:

IFS(
ISNOTBLANK([N1 PHONE 1]), [N1 PHONE 1]& "
", ""
ISNOTBLANK([N1 PHONE 2]), [N1 PHONE 2]& "
", ""
ISNOTBLANK([N1 PHONE 3]), [N1 PHONE 3]
)

IFS(ISNOTBLANK([N1 PHONE 1]), "
" & [N1 PHONE 1])IFS(ISNOTBLANK([N1 PHONE 2]), "
" & [N1 PHONE 2])

Perfect. Thank you very much for your help!

Top Labels in this Space