Forum Discussion
Exchange Rates - Historical
- 1 year ago
Hi Centaur1
Yes, Power Query can fetch historical FX rates up to the current date dynamically:-
Use an API: Find a service like Open Exchange Rates or CurrencyLayer that supports historical rates.
-
Dynamic Query: Use DateTime.LocalNow() in Power Query to set the end date dynamically. Example URL for Open Exchange Rates.
-
Parse Data: Expand the response (JSON/XML) into a tabular format.
-
Refresh Weekly: Set a weekly refresh under Query Properties.
Example script:
let
StartDate = "2014-01-01",
EndDate = Text.From(DateTime.LocalNow()),
Source = Json.Document(Web.Contents("https://openexchangerates.org/api/time-series.json ", [
Query = [app_id = "YOUR_API_KEY", base = "USD", start = StartDate, end = EndDate]
])),
Rates = Table.FromRecords(Source[rates])
in
Rates -
Hi Centaur1,
Thank you Akash_Varuna and rohit1991 for your responses.
As rohit1991 mentioned, Open Exchange Rates and CurrencyLayer provide historical currency exchange rates, but their pricing plans are different. Both services require a paid subscription to access historical data, though they offer free plans for real-time rates. Please check your requirements, such as the number of requests and update frequency, before choosing a plan.
The following services offer free plans:
However, these free plans may have some limits, such as the number of requests allowed per month or the supported currencies. Please check their documentation for more details.
Thank you.
Hello, thank you very much for the follow up. Much appreciated.