我希望根据动态选择的货币代码更改金额。
在我的FactSales表中,我有货币和金额。如果用户希望以任何货币查看该金额,他会从切片机中选择货币,我的兑换率将适用于该金额。
我在DAX下方尝试获得动态汇率,但没有运气:
ExchangeRate = CALCULATE(MIN(ExchangeRate[ExcahngeRate]), FILTER(ExchangeRate, AND(AND(AND(MIN(FactSales[TransDate])>=MIN(ExchangeRate[ValidFrom]), MIN(FactSales[TransDate])<=IF(ISBLANK(MIN(ExchangeRate[ValidTo])), DATEVALUE("01-01-2070"), MIN(ExchangeRate[ValidTo]))), MIN(ExchangeRate[FromCurrencyCode]) = MIN(FactSales[CurrencyCode])), MIN(ExchangeRate[ToCurrencyCode]) = FIRSTNONBLANK(ExchangeRate[ToCurrencyCode],1))))
答案 0 :(得分:0)
如果我们每天都有汇率,那么我们可以采用以下解决方案:
enter link description here:https://www.kasperonbi.com/currency-conversion-in-dax-for-power-bi-and-ssas/
如果我们将汇率作为日期范围,那么使用动态DAX:
ExchangeRate =
IF(ISBLANK
(
CALCULATE(MIN(ExchangeRate[ExcahngeRate]),
FILTER(FILTER(ExchangeRate, AND(AND(ExchangeRate[FromCurrencyCode] = MIN(FactSales[TransactionCurrencyCode]), ExchangeRate[ToCurrencyCode] = FIRSTNONBLANK(ExchangeRate[ToCurrencyCode],1))
, MIN(FactSales[TransDate])<=IF(ISBLANK(ExchangeRate[ValidTo].[Date]), DATEVALUE("2070-01-01"), ExchangeRate[ValidTo]))), MIN(FactSales[TransDate])>= ExchangeRate[ValidFrom]))
)
, 1
, CALCULATE(MIN(ExchangeRate[ExcahngeRate]),
FILTER(FILTER(ExchangeRate, AND(AND(ExchangeRate[FromCurrencyCode] = MIN(FactSales[TransactionCurrencyCode])
, ExchangeRate[ToCurrencyCode] = FIRSTNONBLANK(ExchangeRate[ToCurrencyCode],1))
, MIN(FactSales[TransDate])<=IF(ISBLANK(ExchangeRate[ValidTo].[Date]), DATEVALUE("2070-01-01"), ExchangeRate[ValidTo])))
, MIN(FactSales[TransDate])>= ExchangeRate[ValidFrom]))
)