IS_ACTIVE()
All functions > BUSINESS > IS_ACTIVE()
Returns whether the given activity bits is active for the given time period
Signatures
Returns: Number of active days in the specified period
IS_ACTIVE(activity_bits: BIGINT, length_days: BIGINT, [offset_days: BIGINT]) → BIGINT sql
| Parameter | Type | Required | Description |
|---|---|---|---|
activity_bits | BIGINT | Yes | Bit-packed activity representation |
length_days | BIGINT | Yes | Length of time period to count |
offset_days | BIGINT | No | Optional offset from reference date (default 0) |
Notes
- Checks if user had any activity in specified time window
- offset_days=0 checks most recent period
- offset_days=7 checks week starting 7 days ago
- Returns TRUE if any bit is set in the specified range
- Fast bitwise operation (no date conversions)
- Common for defining "active user" metrics
- Use COUNT_ACTIVE to count specific days instead of boolean
Examples
FeatureQL
SELECT
f1 := IS_ACTIVE(3::BIGINT, 2), -- Any activity in the lowest two day-slots
f2 := IS_ACTIVE(8192::BIGINT, 7, 7) -- Offset window checks activity one week earlier
;Result
| f1 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | true |
On this page