Convert Multi-Currency Ad Spend to USD Using Daily FX Rates
Last updated: November 29, 2026
Quick Overview
Advertisers are billed in local currencies. Given spend (date, advertiser_id, currency, amount) and an FX table (date, currency, usd_per_unit) that has no rows on weekends and holidays, convert spend to USD using the most recent available rate on or before each spend date, and total USD spend per day.
Meta
November 29, 20260
0
0 solved
Advertisers are billed in local currencies. Given spend (date, advertiser_id, currency, amount) and an FX table (date, currency, usd_per_unit) that has no rows on weekends and holidays, convert spend to USD using the most recent available rate on or before each spend date, and total USD spend per day.
Meta bills advertisers in dozens of currencies and reports revenue in USD, so currency conversion with incomplete rate tables is everyday data engineering. The interviewer checks building a complete daily rate calendar with forward fill per currency, joining without dropping rows, and flagging spend with no rate.
What the Interviewer Expects
- Build a full daily calendar per currency and forward-fill rates
- Never use a future rate for a past date
- Treat USD as rate 1 without needing a table row
- Left-join so spend without a rate is visible, not dropped
- Report unconverted amounts separately
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
- Would you convert at the spend date rate or the billing date rate, and why does finance care?
- How would you restate historical revenue in constant currency to remove FX effects?
- How would you do this in SQL without a calendar table?
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
Rates are published on business days only. Spend can occur on any day. USD has rate 1. A spend date earlier than the first known rate for that currency cannot be converted and is reported as missing. ...
Approach
For each currency, reindex the FX series over a daily range from its first date to the max spend date and forward-fill. A pivot then stack is a compact way: pivot rates to date by currency, reindex to...