0

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

在此处输入图像描述

此外,我们还有一张汇率表,其中包含 BaseCurrency(标准货币,即美元、欧元和印度卢比)、目标货币、生效日期和汇率。

在此处输入图像描述

为了分析,我们需要根据汇率日期-生效日期映射即时转换任何基础货币(即美元/印度卢比/欧元)的销售额。我怎样才能做到这一点?

我尝试遵循 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]))

但它会产生“无穷大”的价值。

在此处输入图像描述

4

1 回答 1

0

终于明白了:)

只需要 2 个度量:SalesAmount 用于 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)))
于 2020-06-26T05:47:48.480 回答