Line breaks in formulas


#1

I’m using Airtable to plan some PPC campaigns. I have a formula concatenating a bunch of different keyword sets, which reference the product name from an earlier field in the record.

Google AdWords prefers to have each keyword set on a new line.

Is there any way I can produce a line break in the formula output so that each can be pasted straight in?


#2

Any news about this?


#3

Matt, if you put “\n” in the formula it will work. Since the Formula field is just a one line field, you have to copy the whole cell (without clicking on it).


#4

Bruno, can you show an example of the \n in use please?


#5

\n works. Add it to a formula, and when you copy/paste the results outside of airtable, the line break will be apparent.

Example:
“first line \n second line \n\n fourth line”

Please note - the line breaks are invisible in airtable, unless used in the primary cell.


#6

Here’s an example of the “\n” line break technique.

In this example, the table is being used to store contact info (name, address, etc). A “full address” formula column might be configured with this formula:

Full_Name & "\n" & Street & "\n" & City & ", " & State & " " & Zip

Copying and pasting a cell from that column would result in something like this:

Jenny Eihrtable
657 Airtable Avenue
Jacksonville, FL 55555

~ Tim


#7

Just as Zac and Tim showed. By the way, I think it would be a great implement if we could show the formula field as a multi-line field.


#8

I have tried the “\n” trick, and it does work to create a line break if I copy the field and paste it into Word. However, the result also contains quotation marks at the beginning and end of the field. How can I get rid of those?


#9

In playing about with “new lines” tonight, \n also doesn’t reflect within Grid Views. I am curious if it’s possible to reflect a new line within the grid view of a formula return?


#10

Anyone got an idea on how to avoid the start and end quotations on the pasted multi-line field? It pastes like this:
“12 Appleby Road
Grainborough
Devon
XY5 ABS”


#11

That’s the expected behaviour for copying out of a multiline cell, unfortunately. (You’ll also run into the same problem with Google Sheets)
The last time I had this problem I wrote a small browser extension to modify the clipboard contents, but you might have better luck just removing the quotation marks once you’ve pasted it.


#12

You could wrap the formula in this:

SUBSTITUTE([Formula here], "\"", "")


#13

A couple of notes:

  1. If you copy and paste from the formula field into a long text field, the first four lines of the field will display in gallery and kanban views.

  2. With the new ability to change line height in grid views, the first six lines of a formula field with embedded ‘\n’ characters can be shown when line height is set to ‘extra-tall.’ Presumably this is the same for long text fields, as well; however, unlike the use with gallery and kanban views mentioned in item 1, the value does not have to be copy-and-pasted into a long text field first.

  3. ‘Extra-tall’ line height in grid views, as discussed in item 2, also applies to rollup fields created with the aggregation function ARRAYJOIN(values,'\n').

  4. The Page Designer Block will wrap formula or rollup fields with embedded ‘\n’ characters without requiring the field value first be copy and pasted to a long text field.

  5. In support of the functionality described in item 1, within the [Documentation] table of my Wardrobe Manager base is the ‘Wardrobe Manager Zapier Guide,’ providing step-by-step instructions for configuring a two-step (i.e., free) Zapier Zap to copy the value from a formula field and paste it into a long text field.


#14

Hi Matt
I wrapped the formula as you suggested, but the outcome was the same…
SUBSTITUTE(Business & “\n” & ((IF({BusAdd1} = “”, “”,{BusAdd1} & “\n”) & IF({BusAdd2} = “”, “”,{BusAdd2} & “\n”)) & IF({BusAdd3} = “”, “”,{BusAdd3} & “\n”)) & BusPostCode, “”", “”)


#15

Agreed, SUBSTITUTE([Formula here], “”", “”) doesn’t work to omit these wrapping quotes upon paste outside or Airtable… For now we will have to strip them out in InDesign.

Does anyone know if there is an option for soft returns? It’s my presumption that \n is the equivalent of char(13). Is there an equivalent of char(10)? We’d ideally employ BOTH hard and soft returns, for reason of Style Sheets on the InDesign side.


#16

newline'\n'is char(10), aka linefeed or LF. Unix and other Multics-ish systems use only a single-character indicator for end-of-line. (LF was chosen over the seemingly more-intuitive char(13), carriage return, because that character was typically used to create bold face and underscore [which Markdown doesn’ support] effects on then-standard line printers by printing a line, returning to the start of the line without advancing to the next line, and overprinting or underscoring text as needed.¹)

The CR/LF two-character sequence was a common microcomputer conceit — including, of course, for IBM-compatible PCs.

At one point I fooled around with some other escaped character sequences in Airtable — including '\r', the coding for carriage return — as well as some escaped numeric encodings, and, IIRC, the only one it seemed to recognize was '\n'.

Wikipedia has a nicely concise overview of the whole newline conundrum which still manages to include multiples of the amount of information one would likely care to know.


  1. One of the word processors that shipped with my first PC, a Columbia MPC-1600, had no support for font effects. Until I learned how to hand-embed Okidata printer control codes into my document text, I used the CR-but-no-LF trick for boldface and underscore — which was, believe it or not, as the users guide directed.