Compute Daily DAU Over Trailing 28-Day MAU for Google Chat
Last updated: November 29, 2026
Quick Overview
For each day in October, compute Google Chat DAU, the number of distinct users active in the trailing 28 days ending that day, and their ratio (stickiness), efficiently in BigQuery.
0
0
0 solved
For each day in October, compute Google Chat DAU, the number of distinct users active in the trailing 28 days ending that day, and their ratio (stickiness), efficiently in BigQuery.
Stickiness is a common engagement metric for Google communication products. Onsite, the interviewer is testing whether you know that COUNT(DISTINCT) cannot be used with a sliding window frame in BigQuery and can find a scalable alternative, plus the data needed before the first reporting day.
What the Interviewer Expects
- Recognize that distinct counts over a moving frame need a different approach
- Pull 27 days of history before the first reporting date
- Expand each active day to the 28 report days it belongs to, then dedupe
- Join DAU and MAU and divide safely
- Discuss cost and alternatives such as HyperLogLog sketches or bitmaps
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you make this incremental so each day costs a constant amount?
- How would HLL_COUNT functions change accuracy and cost?
- Why might the DAU over MAU ratio fall even when DAU grows?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
chat_events(user_id, event_ts, event_type). Active means at least one message_sent that day. The 28-day window ending on day d covers d minus 27 through d. Output one row per October day: dau, mau...
Approach
A frame like RANGE BETWEEN 27 PRECEDING AND CURRENT ROW cannot count distinct users. Instead, flip the problem: a user active on day x belongs to the MAU of every report day from x to x + 27. Expand...