Telemetry data is recorded any time a user opens their app. We can understand how many days per month a user opens their app by looking at the number of unique days a telemetry record was recorded for them.
I wanted to share some SQL that can be helpful for those that are interested in knowing how many days per month users are opening their app
The SQL provided below will return a table like this (plus some other useful fields).
user_name | january | february | march |
---|---|---|---|
user123 | 19 | 25 | 27 |
user234 | 12 | 23 | 22 |
user345 | 15 | 17 | 20 |
user456 | 16 | 11 | 19 |
In the example above, user123
opened their app at least once on:
- 19 out of 31 days in January
- 25 out of 28 days in February
- 27 out of 31 days in March
SQL
SELECT
user_name,
count(distinct(period_start)) FILTER (WHERE date_trunc('month',period_start) = '2023-01-01') AS january,
count(distinct(period_start)) FILTER (WHERE date_trunc('month',period_start) = '2023-02-01') AS february,
count(distinct(period_start)) FILTER (WHERE date_trunc('month',period_start) = '2023-03-01') AS march,
count(distinct(period_start)) FILTER (WHERE date_trunc('month',period_start) = '2023-04-01') AS april,
count(distinct(period_start)) FILTER (WHERE date_trunc('month',period_start) = '2023-05-01') AS may,
count(distinct(period_start)) FILTER (WHERE date_trunc('month',period_start) = '2023-06-01') AS june,
count(distinct(period_start)) AS telemetry_days_ytd,
CURRENT_DATE - '2023-01-01'::date AS total_days_ytd,
((count(distinct(period_start)) / (CURRENT_DATE - '2023-01-01'::date)::float)*100)::int AS percent_days_active
FROM
useview_telemetry
WHERE
date_trunc('year',period_start) = '2023-01-01'
GROUP BY
user_name
ORDER BY
telemetry_days_ytd DESC