Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Centaur1
Regular Visitor

Lookup a Currency Rate according to a Date

Hello Experts

 

I have a append query with 3 columns. 

the fields in the append query are Date, Rate, Curr (for Currency).  

I have 4 different currencies:  USD, EUR, GBP, DKK

What I need is to add a column called [USD Amount] in my query called Stampli and this column will lookup the rate based on 3 criteria:  Stampli.[WDDate] and the Stampli.[Currency] but if the currency is USD then use the Stampli.[Amount] (since this is already in USD or could simply use 1 in the calculation for what te currency is USD. 

 

Example:  if Stampli.[WDDate] is 1/26/25 and Stampli.[Currency] = EUR then calcuate the Amount*Rate but noting that if USD then use a 1 as the Rate. 

 

The rate would be the rate according to that Stampli.[WDDate] and Stampli.[Currency]

 

Not sure if I am missing something in my explanation.  

I am a novice user of PQ.  

thank you very much.  

 

here is a clip of what the Append query looks like:

The lookup formula would lookup the rate in this query. 

Centaur1_0-1737925466040.png

 

1 ACCEPTED SOLUTION
rohit1991
Super User
Super User

hi @Centaur1 ,

Here's the concise Power Query M code to calculate USD Amount:

let
// Load queries
Stampli = YourStampliTable,
CurrencyRates = YourCurrencyRateTable,

// Merge Stampli with CurrencyRates
MergedTable = Table.NestedJoin(Stampli, {"WDDate", "Currency"}, CurrencyRates, {"Date", "Curr"}, "MergedRates", JoinKind.LeftOuter),

// Expand the Rate column

ExpandedTable = Table.ExpandTableColumn(MergedTable, "MergedRates", {"Rate"}),

// Add USD Amount column
AddUSDColumn = Table.AddColumn(ExpandedTable, "USD Amount", each if [Currency] = "USD" then [Amount] else [Amount] * [Rate], type number)
in
AddUSDColumn





Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

View solution in original post

4 REPLIES 4
rohit1991
Super User
Super User

hi @Centaur1 ,

Here's the concise Power Query M code to calculate USD Amount:

let
// Load queries
Stampli = YourStampliTable,
CurrencyRates = YourCurrencyRateTable,

// Merge Stampli with CurrencyRates
MergedTable = Table.NestedJoin(Stampli, {"WDDate", "Currency"}, CurrencyRates, {"Date", "Curr"}, "MergedRates", JoinKind.LeftOuter),

// Expand the Rate column

ExpandedTable = Table.ExpandTableColumn(MergedTable, "MergedRates", {"Rate"}),

// Add USD Amount column
AddUSDColumn = Table.AddColumn(ExpandedTable, "USD Amount", each if [Currency] = "USD" then [Amount] else [Amount] * [Rate], type number)
in
AddUSDColumn





Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

Hi Rohit.  that worked!  thank you very much.  

dufoq3
Super User
Super User

Hi @Centaur1, again:

 

Provide sample data in usable format (not as a screenshot) - if you don't know how - read note below my post.
Don't forget to provide also expected result based on sample data.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Akash_Varuna
Super User
Super User

Hi , 

Merge the Stampli table with the Rates table using WDDate and Currency to get the corresponding Rate.

Add a conditional column to calculate [USD Amount]: if Currency = USD, use Amount, otherwise multiply Amount by Rate.

Expand the Rate column from the Rates table.
If this helps please do give a kudos and accept this as a solution

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.