Skip to main content
PYSPARK • LESSON 289

Scenario: Dynamic Cross-Currency Price Normalization

How can we convert multi-currency international transactions to USD using daily fluctuating exchange rate tables?

Production3 Minutes880 XP
🤔 THE QUESTION

How can we convert multi-currency international transactions to USD using daily fluctuating exchange rate tables?

💡 WHAT IS IT?

Joining transactions with exchange rate dimensions on currency code and transaction date calculates standardized USD totals.

🎯 WHAT IS IT USED FOR?

Global retail pipelines consolidating international sales into standardized corporate financial metrics.

💻 EXAMPLE
df_normalized = df_transactions.join(df_fx_rates, (df_transactions.currency == df_fx_rates.currency) & (df_transactions.tx_date == df_fx_rates.rate_date), "left").withColumn("amount_usd", col("amount") * col("usd_exchange_rate"))

🎯 Mission Objectives

Practice typing production-grade PySpark code for Scenario: Dynamic Cross-Currency Price Normalization.

  • Temporal currency exchange join
  • Multi-currency normalization
  • Standardized USD metric calculation