Forum Discussion
Anonymous
7 years agoNot 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.
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?
Anonymous
Try this new custom column
=let mydate=[Date] in Table.Max( Table.SelectRows(#"Exchange Rates",each [Date] <= mydate),"Date")[Rate]
1 Reply
- Zubair_MuhammadCommunity Champion
Anonymous
Try this new custom column
=let mydate=[Date] in Table.Max( Table.SelectRows(#"Exchange Rates",each [Date] <= mydate),"Date")[Rate]