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
Anonymous
Not applicable

Closest lookup date in Power Query / M-language

Hi,

In the Excel table "Purchases" I want to add a New column where I use the Date row to lookup an exchange rate in the "Exchange Rates" table and calculate the new currency cost column based on the original currency and the exchange rate.

 

Table1.png      Table2.png

 

My challenge is that purchase lines may be registered on any date, but the exchange rates are not available for weekends and holidays dates. You can see that there is a purchase row registered on the date 03.08.2019, but there is no exchange rate available for that date in the "Exchange Rate" table because this is a Saturday.

 

Can you please help me how to solve this in Power Query / M language?

 

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

Try this new custom column

 

=let mydate=[Date] in 
Table.Max(
Table.SelectRows(#"Exchange Rates",each [Date] <= mydate),"Date")[Rate]

View solution in original post

1 REPLY 1
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

Try this new custom column

 

=let mydate=[Date] in 
Table.Max(
Table.SelectRows(#"Exchange Rates",each [Date] <= mydate),"Date")[Rate]

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.