PLAYGROUND

Date List Int

A clever analytics technique packs a fixed window of into a compact format to optimize storage and/or aggregation. Inspired by this article.

Interact with the checkboxes below to simulate that a user was active on a given week. You can imagine this being the data stored in your analytics DB. Then select a week to simulate the current time and see if the user was active, retained, etc.


Active weeks

Current Week

Current Week

WhatValueExplanation
Date List[0,0,0,0,0,0,0,0]N-weeks of activity, as an array.
Date List Int0N-weeks of activity, as a decimal integer. Pseudoformula: if active: sum += 2^i
Binary string00000000The DateListInt represented as an 8-bit binary string, padded.
Week bitmask1A decimal power of two with only the selected week’s bit set. JS Formula: Math.pow(2, 0)
Binary string00000001The same week bitmask as a padded 8-bit binary string.
Is active?

No

JS Formula: (0 & 1) > 0
Is retained?

Indeterminate

Active current week AND active previous week
JS Formula: (0 & 1) > 0 && (0 & 0) > 0
The bitwise AND (&) operator returns a number or BigInt whose binary representation has a 1 in each bit position for which the corresponding bits of both operands are 1. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_AND