使用DAX的动态汇率

时间:2017-12-03 06:21:26

标签: dax

我希望根据动态选择的货币代码更改金额。

在我的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))))

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

如果我们每天都有汇率,那么我们可以采用以下解决方案:

enter link description herehttps://www.kasperonbi.com/currency-conversion-in-dax-for-power-bi-and-ssas/

enter image description here

如果我们将汇率作为日期范围,那么使用动态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])) )

enter image description here enter image description here