COUNT_ACTIVE()

All functions > BUSINESS > COUNT_ACTIVE()

Returns the number of active days for the given activity bits and time period

Signatures

Returns: Number of active days in the specified period

COUNT_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

  • Counts number of days user was active in time window
  • Uses efficient BIT_COUNT operation
  • offset_days=0 counts most recent period
  • Returns integer from 0 to length_days
  • More granular than IS_ACTIVE (which returns boolean)
  • Useful for engagement metrics, frequency analysis
  • Common for calculating days active per week/month

Examples

FeatureQL
SELECT
    f1 := COUNT_ACTIVE(3::BIGINT, 2) -- Count set bits in the lowest two day-slots
;
Result
f1 BIGINT
2

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