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
ParameterTypeRequiredDescription
activity_bitsBIGINTYesBit-packed activity representation
length_daysBIGINTYesLength of time period to count
offset_daysBIGINTNoOptional 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 BOOLEANf2 BOOLEAN
truetrue

Last update at: 2026/05/26 17:22:09