Count the times a word appears in a text field

  • 0
  • 1
  • Question
  • Updated 4 years ago
  • Answered

I have a formula text field called "Regions Tagged". Here is an example of data in that field: "U.S. Canada  United Kingdom  Australia  Canada   India"  I'd like to count the number of times the word Canada appears in the text field or flag whenever the word Canada appears more than once.  It appears that this cannot be done with current QuickBase formulas because although they can flag when a word is contained in a text field, they cannot count the number of times the word appears.



Photo of Minda P.

Minda P.

  • 0 Points

Posted 4 years ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,004 Points 20k badge 2x thumb
See this application and visit a display record to display the count of "Canada" in the text field:

Count Instances
https://haversineconsulting.quickbase.com/db/bj4wgaajx

Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=418

Notes:

(1) I only implemented this feature on the display record page

(2) The script can easily be modified to count or match for anything using an appropriate regular expression

(3) The count is not stored in a field - rather it is calculated anew each time a record is displayed

(4) You have permission to add records to test it yourself
Photo of Minda P.

Minda P.

  • 0 Points
Dan, Amazing work as usual!  I appreciate it.  I will try to implement this in my QB later today.