Three parts and I only really nailed the first one cleanly.
Start by clarifying the data schema and assumptions, then outline the SQL or pandas steps to compute the 30-day rolling sum and YoY percentage change. Finally, explain how you would use the most recent YoY% to project next year's revenue, discussing any caveats or validation checks.
Pro tip: Mention that you would validate the rolling sum by checking edge cases (e.g., first 29 days) and ensure the YoY calculation accounts for leap years and missing data. Also, highlight that projecting a full year from a single YoY% assumes seasonality is stable, so you might adjust for known seasonal patterns.
Confirm the table structure (date, revenue), define 'daily ad revenue', and specify the rolling window (30 days) and YoY calculation (same day previous year). Ask about data completeness and time zone.
Use a window function (e.g., SUM(revenue) OVER (ORDER BY date ROWS BETWEEN 29 PRECEDING AND CURRENT ROW)) to calculate the rolling sum for each day. Handle initial days with insufficient data appropriately.
For each day, compute the percentage change between the current rolling sum and the rolling sum from the same day in the previous year. Use a self-join or LAG with date offset, ensuring alignment by date.
Take the most recent YoY% (e.g., yesterday's or today's) and apply it to the corresponding day's revenue from the previous year to estimate next year's daily revenue. Sum these estimates over the next 365 days to get total projected revenue.
Check for outliers, missing data, and seasonality. Discuss limitations of using a single YoY% for projection and suggest alternative methods (e.g., time series forecasting) if needed.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.