CountMatches / List Layer
Count occurrences of a specific value in variable-length lists. Similar to Python's count() method or R's sum(x == value). Returns an integer column with the count of matches in each list. Supports lists of different lengths.
Example transformation:
lists | count_3 |
---|---|
[1, 3, 5, 3, 2] | 2 |
[3, 3, 3] | 3 |
[1, 2] | 0 |
[null, 3, null, 3] | 2 |
[] | 0 |
Common applications:
- Analyzing keyword frequency in text tokens
- Counting error occurrences in log entries
- Tracking event repetitions in session data
- Measuring symptom frequency in medical records
- Detecting pattern frequency in time series
- Analyzing user interaction patterns
Note: Lists can have any length, including empty. Type-sensitive comparison. Null values are ignored in counting unless list contains only nulls, then returns null. Empty lists return 0. Particularly useful for analyzing frequency patterns in variable-length data like logs, transactions, or user behaviors.
Select
columnThe variable-length list column to analyze. Supports various types:
- Numeric lists: [1, 2, 3, 2, 4, 2]
- String lists: [red, blue, red, green]
- Boolean lists: [true, false, true, true]
- Date lists: [2024-01-01, 2024-02-01, 2024-01-01] Lists can have different lengths. Mixed types not supported.
Item
stringThe value to count (Item
). Must match list element type. Examples:
- Numeric: 42 (counts in [42, 1, 42, 3, 42])
- String: error (counts in [warning, error, error])
- Boolean: true (counts in [true, false, true])
- Date: 2024-01-31 (counts in [2024-01-31, 2024-02-01, 2024-01-31])
- Time: 15:30:00 (counts in [15:30:00, 09:00:00, 15:30:00])
AsColumn
nameName for the new column. If not provided, the system generates a unique name. If AsColumn
matches an existing column, the existing column is replaced. The name should follow valid column naming conventions.