Page tree

NOTE:  Trifacta Wrangler is a free product with limitations on its features. Some features in the documentation do not apply to this product edition. See Product Limitations.

   

This example demonstrates how to count the number of occurrences of text patterns in a column.

Functions:

ItemDescription
IF Function The IF function allows you to build if/then/else conditional logic within your transforms.

Source:

The dataset below contains fictitious tweet information shortly after the release of an application called, "Myco ExampleApp".

DatetwitterIdisEmployeetweet
11/5/15lawrencetlu38141FALSEJust downloaded Myco ExampleApp! Transforming data in 5 mins!
11/5/15petramktng024TRUETry Myco ExampleApp, our new free data wrangling app! See www.example.com.
11/5/15joetri221TRUEProud to announce the release of Myco ExampleApp, the free version of our enterprise product. Check it out at www.example.com.
11/5/15datadaemon994FALSEGreat start with Myco ExampleApp. Super easy to use, and actually fun.
11/5/1599redballoons99FALSELiking this new ExampleApp! Good job, guys!
11/5/15bigdatadan7182FALSE@support, how can I find example datasets for use with your product?

There are two areas of analysis:

  • For non-employees, you want to know if they are mentioning the new product by name.
  • For employees, you want to know if they are including cross-references to the web site as part of their tweet.

Transformation:

The following counts the occurrences of the string ExampleApp in the tweet column. Note the use of the ignoreCase parameter to capture capitalization differences:

Transformation Name Count matches
Parameter: Column tweet
Parameter: Option Text or pattern
Parameter: Text or pattern to count 'ExampleApp'
Parameter: Ignore case true

For non-employees, you want to track if they have mentioned the product in their tweet:

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula if(isEmployee=='FALSE' && countpattern_tweet=='1',true,false)
Parameter: New column name 'nonEmployeeExampleAppMentions'

The following counts the occurrences of example.com in their tweets:

Transformation Name Count matches
Parameter: Column tweet
Parameter: Option Text or pattern
Parameter: Text or pattern to count 'example.com'
Parameter: Ignore case true

For employees, you want to track if they included the above cross-reference in their tweets:

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula if(isEmployee=='TRUE' && countpattern_tweet1 == 1, true, false)
Parameter: New column name 'employeeWebsiteCrossRefs'

Results:

After you delete the two columns tabulating the counts, you end up with the following:

DatetwitterIdisEmployeetweetemployeeWebsiteCrossRefsnonEmployeeExampleAppMentions
11/5/15lawrencetlu38141FALSEJust downloaded Myco ExampleApp! Transforming data in 5 mins!falsetrue
11/5/15petramktng024TRUETry Myco ExampleApp, our new free data wrangling app! See www.example.com.truefalse
11/5/15joetri221TRUEProud to announce the release of Myco ExampleApp, the free version of our enterprise product. Check it out at www.example.com.truefalse
11/5/15datadaemon994FALSEGreat start with Myco ExampleApp. Super easy to use, and actually fun.falsetrue
11/5/1599redballoons99FALSELiking this new ExampleApp! Good job, guys!falsetrue
11/5/15bigdatadan7182FALSE@support, how can I find example datasets for use with your product?falsefalse

See Also for EXAMPLE - Countpattern Transform:

This page has no comments.