Help

Generate string of text from multiple number columns

Topic Labels: Formulas
Solved
Jump to Solution
1685 2
cancel
Showing results for 
Search instead for 
Did you mean: 
JCtriostar
4 - Data Explorer
4 - Data Explorer

I’ve searched the forum and tried to figure the formula out on my own but I’m not even sure if this is possible in Airtable. Any help would be appreciated. I have multiple columns where entries are either numbers or blank. I’d like to be able to generate a phrase that puts all these numbers and field names together as text.

xfieldname is the name of the column. All cells in the column are numbers or blank.
xvalue is the number in the column.

Final field is text
If xvalue > 0, return “xvalue xfieldname”
If not, return blank
[insert comma]
If yvalue > 0, return “yvalue yfieldname”
If not, return blank

Final output is:
xvalue xfieldname, yvalue yfieldname

I’ve tried:
IF({Set of Pins}>0, “{Set of Pins} set of pins”, “”)
Which of course produced “{Set of Pins} set of pins” instead of the actual number in the column.

Example:
If the “pairs of socks” column has “2”, the “hats” column has “3”, and the “set of pins” column is blank, the final output is:
2 pairs of socks, 3 hats

1 Solution

Accepted Solutions
Kamille_Parks
16 - Uranus
16 - Uranus

That’s almost right, you’ll need to do this instead:
IF({Set of Pins}>0, {Set of Pins} & ' set of pins')&', '&IF({Hats}, {Hats} & ' hats')

In writing Airtable formulas, plain text goes in straight quotes or apostrophes, and values from fields are outside of quotes in curly braces. the &', '& between those two IF() statements just adds a comma between the two fields.

See Solution in Thread

2 Replies 2
Kamille_Parks
16 - Uranus
16 - Uranus

That’s almost right, you’ll need to do this instead:
IF({Set of Pins}>0, {Set of Pins} & ' set of pins')&', '&IF({Hats}, {Hats} & ' hats')

In writing Airtable formulas, plain text goes in straight quotes or apostrophes, and values from fields are outside of quotes in curly braces. the &', '& between those two IF() statements just adds a comma between the two fields.

Thank you SO MUCH. I just tested it with a few filled and unfilled columns and it worked! I ended up moving the commas to within the straight quotes instead of with the ampersand so I didn’t have random commas in between if the fields were blank. You’re a lifesaver.