如何根据 Power BI 中的截止日期获取汇率?

How to get the Exchange Rate based on the Closing Date in Power BI?

我有一个 Table 汇率,其中包含 Date/Time 格式的日期和汇率。我想根据日期的最大值获取汇率。 例如:

Date: 22/07/2019 11:00    Exchange Rate: 77.83
      22/07/2019 11:45                   75.00
      17/07/2019 12:00                   90.00

现在我需要得到结果 77.83

您需要创建一个新度量:

LatestExchangeRate = 
var maxDate = MAX(rateTable['Date'])

return 
CALCULATE(
    SELECTEDVALUE(rateTable['Exchange Rate']), 
    FILTER(
        rateTable, 
        rateTable['Date'] = maxDate
    )
)

说明: 我们通过 maxDate 过滤 table 并得到一行。从这一行我们 select 汇率