Rolling Twenty-Eight Day Conversion Rate as a Ratio of Rolling Sums

Last updated: November 29, 2026

Quick Overview

For each Meta ad account, compute a trailing 28-day conversion rate (conversions over clicks) for every day, and show why it must be the ratio of rolling sums rather than the average of daily rates. Days without activity must not shrink the window.

Meta
Data Manipulation (SQL/Python)
Data Scientist
Meta
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


For each Meta ad account, compute a trailing 28-day conversion rate (conversions over clicks) for every day, and show why it must be the ratio of rolling sums rather than the average of daily rates. Days without activity must not shrink the window.

Asked in Meta ads measurement interviews, where advertiser-facing reports show rolling conversion rates and averaging daily ratios is a frequent bug. The interviewer checks the frame definition over dates, not rows, and the weighting of the ratio.

What the Interviewer Expects
  • Sum numerator and denominator separately over the window
  • Use a date-based frame (RANGE with an interval) or a dense spine
  • Explain the bias of averaging daily rates
  • Guard against zero clicks
  • Restrict to days with a full window
Key Topics to Cover
rolling ratio
RANGE frames
weighted averages
conversion rate
attribution lag
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • When would an average of daily rates be the right metric?
  • How do you put a confidence interval on the rolling rate?
  • Conversions are attributed up to 7 days after a click: how does that affect the latest days?
  • How would you compute this for all accounts efficiently?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

ad_account_daily(ad_account_id, ds, clicks, conversions), one row per account per day with any clicks; quiet days have no row. The window for day D is D-27 to D inclusive. My engine supports `RANGE ...

Approach

Average of daily rates gives each day equal weight, so a day with 2 clicks and 1 conversion (50%) counts as much as a day with 5,000 clicks. The correct rolling rate is total conversions over total cl...


Submit Your Answer
Markdown supported