RECENCY
All functions > BUSINESS_ACTIVITY > RECENCY
Returns the number of days since the last active day for the given activity bits
Syntax
RECENCY(activity_bits: BIGINT) → BIGINT
sql
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
activity_bits | BIGINT | Yes | Bit-packed activity representation |
Returns
BIGINT - Number of days since last activity (0 = today, 1 = yesterday, etc.), NULL if never active
Notes
- Finds most recent active day using bit operations
- Returns 0 if active today, 1 if yesterday, etc.
- Returns NULL if activity_bits = 0 (never active)
- Uses efficient bit isolation technique (x & -x)
- Fast operation - no iteration required
- Essential for recency analysis and churn prediction
- Complements frequency metrics from COUNT_ACTIVE