Cumulative Unique Reach and Average Frequency by Campaign Day

Last updated: November 29, 2026

Quick Overview

From raw ad impression logs, compute for each campaign and day the cumulative number of unique users reached so far, cumulative impressions, and average frequency (impressions per reached user) to date.

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

0

0

0 solved


From raw ad impression logs, compute for each campaign and day the cumulative number of unique users reached so far, cumulative impressions, and average frequency (impressions per reached user) to date.

Reach and frequency are headline metrics in Ads Manager, and cumulative unique reach is a known trap because distinct counts do not add across days. The interviewer wants the first-exposure trick: count each user only on the day they were first reached, then take a running sum.

What the Interviewer Expects
  • Explains why summing daily unique users overcounts cumulative reach
  • Finds each user's first impression day per campaign
  • Running-sums new reach and impressions per campaign by day
  • Divides cumulative impressions by cumulative reach for frequency
  • Handles days with impressions but no newly reached users
Key Topics to Cover
cumulative distinct count
first-exposure trick
running SUM
reach and frequency
Ads Manager
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
  • How would you compute rolling seven-day reach, which cannot use the first-exposure trick directly?
  • At Meta scale, how would approximate distinct counting (HyperLogLog sketches) change this pipeline?
  • How would you report reach for a campaign split across Facebook and Instagram without double counting cross-app users?
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

Table: ad_impressions(campaign_id, user_id, impression_at). Duplicate rows are real repeat impressions. I report by impression date....

Approach
  1. First impression date per (campaign_id, user_id); counting users by that date gives new reach per day.
  2. Impressions per campaign per day.
  3. Left join new reach onto daily impressions (every ...

Submit Your Answer
Markdown supported