Power BI 汇率计算

Power BI exchange rate calculation

我是 Power BI 桌面的新手。 我们有一个包含 RateDate、orderAmount 和交易货币

的销售交易 table

此外,我们还有汇率 table 与基本货币(标准货币,即美元、欧元和印度卢比)、目标货币、生效日期和汇率。

为了进行分析,我们需要根据汇率日期-生效日期动态映射以任何基础货币换算销售额,即 USD/INR/EUR。 我怎样才能做到这一点?

我尝试了以下 DAX 代码,

AmountUSD = SUMX(Fact_SalesOrder,[OrderAmount]/lookupvalue(CurrencyRates[Rate],CurrencyRates[Effective Date],Fact_SalesOrder[RateDate],CurrencyRates[Base Currency],"USD",CurrencyRates[Target Currency],Fact_SalesOrder[Currency]))

但它的结果是 'infinity' 值。

终于明白了:)

只需要 2 个度量:SalesAmount for Sales 和 Selected currency 供选择。

Selected Currency = VALUES('ReportingCurrencies'[Currency])

SalesAmount = SWITCH(TRUE(),
[Selected Currency] = "EUR",SUMX(Fact_SalesOrder,[OrderAmount]/lookupvalue(CurrencyRates[Rate],CurrencyRates[Effective Date].[Date],Fact_SalesOrder[RateDate].[Date],CurrencyRates[Base Currency],"EUR",CurrencyRates[Target Currency],Fact_SalesOrder[Currency],1)),
[Selected Currency] = "USD",SUMX(Fact_SalesOrder,[OrderAmount]/lookupvalue(CurrencyRates[Rate],CurrencyRates[Effective Date].[Date],Fact_SalesOrder[RateDate].[Date],CurrencyRates[Base Currency],"USD",CurrencyRates[Target Currency],Fact_SalesOrder[Currency],1)),
[Selected Currency] = "INR",SUMX(Fact_SalesOrder,[OrderAmount]/lookupvalue(CurrencyRates[Rate],CurrencyRates[Effective Date].[Date],Fact_SalesOrder[RateDate].[Date],CurrencyRates[Base Currency],"INR",CurrencyRates[Target Currency],Fact_SalesOrder[Currency],1)))