Help

Wordcount formula?

Topic Labels: Formulas
Solved
Jump to Solution
1712 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Ana_Capucho
5 - Automation Enthusiast
5 - Automation Enthusiast

How can I do a word count of a record?
I have a table to organize what I write divided by scenes and I want to count the words in every scene.
Thanks in advance.

1 Solution

Accepted Solutions
Sheryl_Baptista
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi @Ana_Capucho, I was looking into this as well today and found this page https://support.airtable.com/hc/en-us/articles/360035351893-Word-and-character-counts

They recommend using LEN({Text Field}) - LEN(SUBSTITUTE({Text Field}, ’ ', ‘’))+1

I’ve only started using it, but it has been working for me. Hope it’s what you’re looking for! :slightly_smiling_face:

Edit: I realized that it doesn’t return 0 for when there’s no text at all (instead it returns 1). So I got around that by modifying the above formula to return 0 when there is no text.

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

See Solution in Thread

2 Replies 2
Sheryl_Baptista
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi @Ana_Capucho, I was looking into this as well today and found this page https://support.airtable.com/hc/en-us/articles/360035351893-Word-and-character-counts

They recommend using LEN({Text Field}) - LEN(SUBSTITUTE({Text Field}, ’ ', ‘’))+1

I’ve only started using it, but it has been working for me. Hope it’s what you’re looking for! :slightly_smiling_face:

Edit: I realized that it doesn’t return 0 for when there’s no text at all (instead it returns 1). So I got around that by modifying the above formula to return 0 when there is no text.

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

Thomas_de_Beauc
6 - Interface Innovator
6 - Interface Innovator

This method doesn't work when there are extra spaces at the beginning / end of the text or multiple spaces between words, and this happens so often.

Here is a formula that handles that :

 

IF(TRIM(REGEX_REPLACE({Text field}, '\\s+', ' '))=BLANK()
, 
  0
,
  LEN(TRIM(REGEX_REPLACE({Text field}, '\\s+', ' ')))
  - LEN(SUBSTITUTE(
      TRIM(REGEX_REPLACE({Text field}, '\\s+', ' '))
    ,
      ' ', ''
    ))
  + 1
)