Data Analysis & SQL5.0 · 0 ratings

Currency And Unit Normalization For Reporting

Builds SQL to convert multi-currency or mixed-unit transactions to a single reporting basis with correct rates.

Role-BasedChain-of-ThoughtStructured-Output

Prompt

ROLE: You are a finance data analyst who consolidates multi-currency data into one reporting currency.

CONTEXT: Transactions in [TRANSACTIONS_TABLE] carry amounts in their local currency (columns: amount, currency_code, transaction_date). Exchange rates live in [FX_RATES_TABLE] (currency_code, rate_to_[REPORTING_CURRENCY], rate_date). Engine: [DATABASE_ENGINE].

TASK:
1. Decide the rate-matching rule: use the rate effective on the transaction date (most recent rate on or before that date), not today's rate, and explain why for financial accuracy.
2. Write SQL that joins each transaction to the correct historical rate and converts to [REPORTING_CURRENCY].
3. Handle missing rate dates by carrying forward the last known rate (as-of join) and flag any transaction with no available rate.
4. Aggregate converted amounts by [DIMENSION] and period.
5. Add a reconciliation check: converted totals by currency should sum to the grand total.

OUTPUT FORMAT: Rate-matching rule -> Conversion ```sql``` (as-of join) -> Missing-rate handling -> Aggregation -> Reconciliation query.

CONSTRAINTS: Never apply the current rate to historical transactions. Use the latest rate on or before the transaction date. Round only at the final reporting step, not per row, and state the rounding rule. Surface, do not silently drop, transactions lacking a rate.

How to use this prompt

  1. 1

    Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.

  2. 2

    Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.

  3. 3

    Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.

Techniques in this prompt

Role-Based

Assigns the model an expert persona so it adopts the right vocabulary, depth, and standards for the task.

Learn this technique
Chain-of-Thought

Asks the model to reason step by step before answering — ideal for multi-step, logical, or analytical tasks.

Learn this technique
Structured Output

Pins the response to a defined structure so it drops straight into your workflow.

Learn this technique

Recommended models

claudegpt-4ogemini

Build on this prompt

Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.

More in Data Analysis & SQL