Year-over-Year Ads Revenue Aligned to the Same Weekday

Last updated: November 29, 2026

Quick Overview

Compare each day's Meta ads revenue to the same weekday one year earlier by aligning on a 364-day offset, and also compare trailing seven-day totals. Explain why a 365-day offset misleads around events like Black Friday.

Meta
Data Manipulation (SQL/Python)
Data Scientist
Meta
November 29, 2026
Data Scientist
Phone Screen
Data Manipulation (SQL/Python)
Easy

0

0

0 solved


Compare each day's Meta ads revenue to the same weekday one year earlier by aligning on a 364-day offset, and also compare trailing seven-day totals. Explain why a 365-day offset misleads around events like Black Friday.

A short question in Meta's ads finance and analytics screens, where revenue is reported year over year and weekly cycles are strong. The interviewer checks a self-join on a shifted date and whether you understand weekday alignment.

What the Interviewer Expects
  • Self-join on the date shifted by 364 days
  • Explain the weekday alignment
  • Add a trailing 7-day comparison to smooth daily noise
  • Handle missing prior-year days with a LEFT JOIN
  • Note moving holidays
Key Topics to Cover
date offsets
self-join
year over year
seasonality
rolling sums
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 handle the leap day in 2028?
  • Black Friday is a fixed weekday but Easter moves: how do you compare Easter week?
  • How would you adjust for currency movements?
  • Why might YoY growth on a single day be misleading after a product launch?
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

ads_revenue_by_day(ds, revenue_usd), one row per day, complete history. Revenue is in USD at the daily exchange rate. I compare against ds - 364 days, which is exactly 52 weeks back, so Fridays li...

Approach

Compute a trailing seven-day sum with a window, then LEFT JOIN the table to itself on the 364-day-shifted date. Daily YoY growth is the current over the prior minus one, and the 7-day version uses the...


Submit Your Answer
Markdown supported