Adding a modified version of this report here that shows just the MAU (Monthly Active Users) statistics in case this might be helpful for anyone:
MAU (Monthly Active Users)
-- [params]
-- date :start_date = 2024-01-01
-- date :end_date = 2025-01-01
WITH date_series AS (
SELECT generate_series(:start_date::date, :end_date::date, '1 month'::interval) AS month_start
),
MAU AS (
SELECT
date_trunc('month', date_series.month_start) AS month,
COUNT(DISTINCT user_visits.user_id) AS mau_count
FROM user_visits
JOIN date_series
ON date(user_visits.visited_at) >= date_series.month_start - INTERVAL '1 month'
AND date(user_visits.visited_at) < date_series.month_start + INTERVAL '1 month'
GROUP BY date_trunc('month', date_series.month_start)
)
SELECT
month::date AS "Month",
mau_count AS "Monthly Active Users"
FROM MAU
WHERE month <= CURRENT_DATE
ORDER BY month
Example Results
| Month | Monthly Active Users |
|---|---|
| 2024-07-01 | 2 |
| 2024-08-01 | 3 |
| … | … |