If you search the Microsoft Fabric / Power BI community for "exchange rate", you find the same handful of questions asked again and again, mostly by analysts, not developers. I went through six of the common ones and wrote down the answers I'd give, with copy-paste Power Query and DAX.
Quick disclosure: I work on AllRatesToday, and the examples use it because it serves the ECB rates as plain JSON with no key needed. The DAX parts work with any rate table.
1. "Historical exchange rate API – the ECB API is too hard, is there an easier way?"
The poster wanted historical and daily-updated rates, had tried the ECB's own REST API, and (fairly) found it difficult. The ECB API returns SDMX/XML, which is painful in Power Query if you're not a developer.
The easiest route I know: get the same ECB reference rates as JSON. In Power BI Desktop, go to Get Data → Blank Query → Advanced Editor, paste this and click Done:
let
StartDate = #date(2024, 1, 1),
Today = Date.From(DateTime.LocalNow()),
Range = Date.ToText(StartDate, "yyyy-MM-dd") & ".." & Date.ToText(Today, "yyyy-MM-dd"),
Source = Json.Document(
Web.Contents(
"https://allratestoday.com",
[
RelativePath = "api/compat/frankfurter/" & Range,
Query = [base = "EUR", symbols = "USD,GBP,SEK,NOK,DKK"]
]
)
),
Days = Record.ToTable(Source[rates]),
WithPairs = Table.AddColumn(Days, "Pairs", each Record.ToTable([Value])),
Removed = Table.RemoveColumns(WithPairs, {"Value"}),
Expanded = Table.ExpandTableColumn(Removed, "Pairs", {"Name", "Value"}, {"Currency", "Rate"}),
Renamed = Table.RenameColumns(Expanded, {{"Name", "Date"}}),
Typed = Table.TransformColumnTypes(Renamed, {{"Date", type date}, {"Currency", type text}, {"Rate", type number}})
in
Typed
If it asks how to connect, pick Anonymous. You get a table with Date | Currency | Rate. Change the start date and the currency codes to suit you.
Because the end date is always "today", every refresh pulls the newest rate. Publish, turn on scheduled refresh, and set it for late afternoon, because the ECB updates around 16:00 CET.
I call that table FX in the rest of this post.
2. "Exchange rates data not refreshing in the Service"
Works in Desktop, fails in the Power BI Service. Nine times out of ten this is the dynamic data source problem: the query builds the whole URL as one string, so the Service can't work out what it's connecting to and refuses to refresh it.
The fix is to keep the base URL as a fixed string and put everything that changes into RelativePath and Query:
// Breaks scheduled refresh
Web.Contents("https://example.com/api/" & DateText & "?base=EUR")
// Refreshes fine
Web.Contents("https://example.com", [RelativePath = "api/" & DateText, Query = [base = "EUR"]])
The query in #1 already does this. Two other things to check: set the credential to Anonymous (or whatever the API needs) under the dataset settings, and if Power BI complains about privacy levels when you combine the rates with your own data, set the rates source to Public.
3. "Exchange rates – best website to use for historical data?"
Some answers to this sort of question suggest scraping a site like x-rates or xe.com with the Web connector. I'd avoid that. Scraping breaks whenever the page layout changes, it's usually against the site's terms, and an auditor won't be impressed by "a rate I scraped".
What to use depends on what the report is for:
- Management dashboards: any decent daily rate is fine. The ECB reference rates (about 30 currencies, back to 1999) are free and the query in #1 covers them.
- Anything that touches accounting (month-end revaluation, statutory reporting, tax): use the official rate your policy names, often your own central bank's or tax authority's. That isn't always the ECB. AllRatesToday also has central bank and tax authority tables (Fed H.10, Bank of England, HMRC monthly rates and so on) in the same JSON shape, with a free API key.
Whatever you pick, keep the date of the rate in your table. When someone asks in six months why March used 1.0842, you want the answer in the data.
4. "Beginner – exchange rate API"
The classic beginner mistake is calling the API once per row: you add a custom column that calls a function for each transaction's date. It works on 50 rows, then crawls (or hits a rate limit) on 50,000.
Do it the other way round:
- Pull the whole date range once (query #1 does this in one call).
- Load it as its own table.
- Join it to your transactions with a relationship or a merge.
One call per refresh instead of one per row, and it's much faster.
5. "Calculate exchange rate for every day" / "Exchange rate conversion with a date range"
You have sales in several currencies and want everything in one currency, using the rate of each sale's date. The catch that trips everyone up: there are no rates on weekends or bank holidays, so a Saturday sale finds nothing.
This measure uses the latest rate on or before each sale's date. It assumes Sales[Currency] holds the currency of the amount, and that FX is based on EUR (from #1):
Amount EUR =
SUMX (
Sales,
VAR d = Sales[OrderDate]
VAR c = Sales[Currency]
VAR lastDate =
CALCULATE ( MAX ( FX[Date] ), FX[Date] <= d, FX[Currency] = c, REMOVEFILTERS ( FX ) )
VAR rate =
CALCULATE ( MAX ( FX[Rate] ), FX[Date] = lastDate, FX[Currency] = c, REMOVEFILTERS ( FX ) )
RETURN
IF ( c = "EUR", Sales[Amount], DIVIDE ( Sales[Amount], rate ) )
)
Note the divide: with base = "EUR", a USD rate of 1.08 means 1 EUR = 1.08 USD, so a USD amount divided by 1.08 gives EUR. Getting the direction backwards is the second most common bug in these threads.
If you'd rather avoid the DAX, you can fill the gaps in Power Query instead: merge FX with a full calendar table, sort by currency and date, then use Fill Down. After that every day has a rate and a plain relationship works.
6. "Live currency exchange rate"
Worth being clear on this one: DAX can't fetch anything. Measures only see data already loaded into the model. "Live" in Power BI really means "as fresh as your last refresh".
Options, from simplest:
- Daily is enough (it is for most reports): use #1 with scheduled refresh. Up to 8 refreshes a day on Pro, 48 on Premium.
-
You need intraday rates: point the same pattern at a live endpoint and refresh more often. AllRatesToday's
/api/v1/ratesgives a current mid-market rate (with a free key). Your rates are still only as fresh as the last refresh. - Truly live on screen: that's a job for a custom visual or an embedded web page, not the dataset.
For anything financial, I'd use daily official rates anyway. A report whose numbers change every hour is hard to reconcile.
Summary
| Problem | Fix |
|---|---|
| ECB API too hard | Same ECB rates as JSON, one Power Query (#1) |
| Works in Desktop, not in the Service | Fixed base URL plus RelativePath/Query
|
| Which source? | ECB for dashboards; your official central bank or tax rate for accounting |
| Slow refresh | One call for the date range, not one per row |
| Weekends have no rate | Use the latest rate on or before the date |
| "Live" rates | DAX can't fetch; refresh more often or use a live endpoint |
If there's a currency question I missed, leave it in the comments and I'll add it.
More detail: Central bank exchange rates in Power BI.
Top comments (0)