Forum Discussion
Native Query brings all data in tabular visual when currency conversion is applied.
- 1 year ago
All,
I wanted to inform that the issue was resolved.
A Date bridge table containing column with the first of month was added.
This date bridge table was joined to the Exchange Rate Table via a many-to-one join.
The date bridge table is then joined to the fact table via a one to many join.
The DAX query was then updated accordingly, and this resolved the issue.
Hi Rdarshana,
Issue is with The currency conversion logic:
VAR FilteredRates =
FILTER(
'monthly_average_exchange_rate',
...
)
VAR ConversionRate =
MAXX(FilteredRates, 'monthly_average_exchange_rate'[Rate])
doesn’t evaluate per date row but is re-evaluated per row in your visual, and because you’ve added the ID field, that evaluation is multiplied dramatically.
Even worse, your model involves:
-
A many-to-many relationship (between Fact and exchange rate table on
Exchange Rate Date) -
Filtering using
SELECTEDVALUE()on potentially non-unique combinations (To_Currency,From_Currency,Rate Date) -
A complex, dynamic filter (
>=,<=) for each record
This forces row context → filter context conversion per row in the table, generating large native queries.
You can try below methods
Refactor the conversion logic using TREATAS, which lets you push filters from calculated values more cleanly:
Converted Measure =
VAR ConversionStartDate = MIN('Calendar'[Date])
VAR ConversionEndDate = MAX('Calendar'[Date])
VAR TargetCurrencyCode = SELECTEDVALUE('To_Currency'[Currency Code])
VAR SourceCurrency = SELECTEDVALUE('Fact Table'[Currency Code])
VAR RateDates =
ADDCOLUMNS(
CALENDAR(
EOMONTH(ConversionStartDate, -1) + 1,
EOMONTH(ConversionEndDate, -1) + 1
),
"FromCurrency", SourceCurrency,
"ToCurrency", TargetCurrencyCode
)
VAR FilteredRates =
CALCULATETABLE(
'monthly_average_exchange_rate',
TREATAS(RateDates,
'monthly_average_exchange_rate'[Rate Date],
'monthly_average_exchange_rate'[From Currency],
'monthly_average_exchange_rate'[To Currency]
)
)
VAR ConversionRate = MAXX(FilteredRates, 'monthly_average_exchange_rate'[Rate])
RETURN
IF(
TargetCurrencyCode = "USD",
SUM('Fact Table'[Measure1]),
IF(
NOT ISBLANK(ConversionRate),
SUM('Fact Table'[Measure1]) * ConversionRate,
BLANK()
)
)
This ensures rate filtering happens in bulk, not row by row.
you can try below as well,
Instead of applying exchange rate per record, try:
-
Pre-aggregating measure per month
-
Then doing conversion using a monthly average exchange rate
This drastically reduces the calculation context:
Converted Measure (Monthly) =
SUMX(
VALUES('Calendar'[MonthYear]), -- or RateDate
VAR MonthlyTotal =
CALCULATE(SUM('Fact Table'[Measure1]))
VAR Rate =
CALCULATE(
MAX('monthly_average_exchange_rate'[Rate]),
FILTER('monthly_average_exchange_rate', ...)
)
RETURN MonthlyTotal * Rate
)
🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!