Extracting text from fields in Airtable
  • 12 Dec 2023
  • 3 Minutos para leer
  • Oscuro
    Ligero
  • PDF

Extracting text from fields in Airtable

  • Oscuro
    Ligero
  • PDF

The content is currently unavailable in Spanish. You are viewing the default English version.
Resumen del artículo

This article covers how to extract specified values from fields to streamline your team's and organization's work.

Introduction

Plan availability

All plan types 

Platform(s)

Web/Browser, Mac app, and Windows app

Related reading

Using LEN() in Airtable

Using LEN()

This is a very straightforward function that simply returns the length of a string. You can reference a value / field / string within the function following this format: LEN(string).

360099325994len-1.jpg

LEN  ({File})

A popular use for this function is determining word and character counts in order to alert you if you've ran over a specified limit (word counts for blog articles, tweets).

Let's say that you have a base setup to track social media content, and want to make sure your tweets don't exceed the 280 character limit. You can use a formula like the following to output the character count of the text field:

LEN  ({Long Text})

360101548533len-2.jpg

Displaying a message based on character count

Now, let's say that you're not so interested in the exact character count, but more so that you're under the 280 character limit. Here's an example of an IF statement you can write to check for this and output a message depending on the character count:

IF(LEN ({Long Text})>280, "❌Over Limit" , "✅Under Limit" )

1500000449682len-3.jpg

Using this formula, you'll see either ❌Over Limit or ✅Under Limit for each record depending on the character count in the field your formula is watching.

360099326034len-4.jpg

Counting words

For a different workflow, you may be writing editorial content and want to ensure your articles don't exceed a certain word count. You can use a similar formula to count the number of spaces in a text field, which in turn will give you a total count of words.

IF({Text Field}=BLANK(), 0, LEN({Text Field}) - LEN(SUBSTITUTE({Text Field}, ' ', ''))+1)

360099326014len-5.jpg

Using LEFT() and RIGHT() in Airtable

Using LEFT() and RIGHT()

The LEFT() and RIGHT() functions work similarly to one another by extracting a certain number of characters from the beginning (left) or end (right) of a string.

  • LEFT("quick brown fox", 5) would result in "Quick"

  • RIGHT("quick brown fox", 3) would result in "Fox"

These are helpful functions when to use when you need to extract data from a number of records that share a similar structure. For example, you may be importing a dataset where a single cell contains both a date string and a text string, like 02-25-2018_In-Progress.

Assuming that the dates follow the same format of DD-MM-YYYY, you can use LEFT() to extract the date from the full field value:

LEFT  ({Field Name},  10  )

Using MID() in Airtable

Using MID()

This function lets you extract a certain number of characters starting at a specific place within a string. It follows this format: MID(string, whereToStart, count). Let's use the example field value from the previous section to demonstrate.

For a field that contains this value, 02-25-2018_In-Progress, we might want to only extract the status portion of the string. Since the dates always follow the same format, and the underscore character is always the 11th character in the string, we want to extract any text past that (starting at the 12th character) to obtain the status.

MID  ({Field Name},  12  ,  30  )

1500000450302mid-1.jpg

The 30 specified at the end is the count of characters I want to extract. This is a number of characters set to account for the different statuses that may be present in the dataset (e.g. Not Started, Complete). You can always set an arbitrarily high number of characters (like 100, 500, 1000, etc) to account for variations in the dataset.

Using arrays in Airtable

Using arrays

When working with rollup or lookup fields, the value that is returned is formatted as an array. An array can contain a list of values, rather than a single value, and is treated differently than a plain string of text (even if that string had multiple values).

360099327114wwarray-1.jpg

When using arrays with any of the functions covered in this article, you'll run into an error if you just try to reference the array.

1500000450322wwarray-2.jpg

You'll need to join the items in the array into a string in order to use these functions. The adjusted formula LEN(ARRAYJOIN({Lookup Task Code})) will convert the arrayed results on the lookup into a readable string, and then return the length of that string.

360101549373wwarray-3.jpg


¿Te ha sido útil este artículo?