Excel / SQL data preparation · Original fictional case · Free files and answers
Audit ambiguous dates and mixed currencies
A travel-expense import mixes date conventions and currency labels. Produce an accepted ledger from the declared source convention, leaving ambiguous and unsupported records for review.
Suggested time: 15–25 minutes. All records, companies, rates and work policies are invented for this exercise.
Your output contract
- The supplied dates are valid calendar dates. DMY means day/month/year; MDY means month/day/year; ISO means YYYY-MM-DD. UNKNOWN must be held.
- amount_minor represents hundredths for the USD and EUR rows. The training rate is exactly EUR 1 = USD 1.10; it is fictional, not a market quote.
- Accept only declared dates and currencies in rates. Output expense_id,iso_date,usd_cents sorted by expense_id; retain zero expense E05.
Required columns: expense_id, iso_date, usd_cents. Row order is part of the contract. Empty output CSV fields represent NULL; zero remains 0.
Original source tables
expenses
6 source rows · Download expenses CSV
| expense_id TEXT | raw_date TEXT | date_format TEXT | currency TEXT | amount_minor INTEGER |
|---|---|---|---|---|
| E01 | 11/04/2026 | DMY | USD | 12000 |
| E02 | 11/04/2026 | MDY | USD | 8500 |
| E03 | 11/04/2026 | UNKNOWN | USD | 5000 |
| E04 | 2026-11-06 | ISO | EUR | 7000 |
| E05 | 2026-11-07 | ISO | USD | 0 |
| E06 | 2026-11-08 | ISO | JPY | 900 |
rates
2 source rows · Download rates CSV
| currency TEXT | usd_numerator INTEGER | usd_denominator INTEGER |
|---|---|---|
| USD | 1 | 1 |
| EUR | 11 | 10 |
Plan the transformation
- Interpret E01 as 11 April and E02 as 4 November from their separate metadata.
- Hold E03 for a date convention and E06 for a missing currency policy.
- Join the declared rate and calculate integer cents. Keep rate assumptions beside the delivered file.
Watch for this mistake
A computer locale guesses a date convention. A currency symbol or an unlabeled number does not establish an exchange rate.
Run and check your SQLite result
The database runs locally in a worker. Use one SELECT or WITH query. Your query is saved on this device when storage is available. Download your SQL before clearing browser data.
Or work in Excel or another spreadsheet, then upload the final CSV with exactly the required columns.
Worked SQL and complete expected output
Accepted four rows total 28,200 USD cents. E03 and E06 are held, not silently converted.
SELECT e.expense_id,CASE date_format WHEN 'DMY' THEN substr(raw_date,7,4)||'-'||substr(raw_date,4,2)||'-'||substr(raw_date,1,2) WHEN 'MDY' THEN substr(raw_date,7,4)||'-'||substr(raw_date,1,2)||'-'||substr(raw_date,4,2) ELSE raw_date END iso_date,amount_minor*usd_numerator/usd_denominator usd_cents FROM expenses e JOIN rates r USING(currency) WHERE date_format IN ('DMY','MDY','ISO') ORDER BY expense_id;| expense_id | iso_date | usd_cents |
|---|---|---|
| E01 | 2026-04-11 | 12000 |
| E02 | 2026-11-04 | 8500 |
| E04 | 2026-11-06 | 7700 |
| E05 | 2026-11-07 | 0 |
Download reference SQL · Download complete expected CSV · Download an empty answer CSV · Download SQLite setup
What to pass to a colleague
Keep the checked output and SQL or spreadsheet result. Explain the exception policy, the cross-check above and any held records. The checker confirms this fixed case’s output; it does not evaluate arbitrary private business data.
SQLite SELECT, joins and aggregation reference · Continue with the larger workplace projects