The Reporting Amount measure begins by getting the currency selected in the slicer and storing this value in the __ReportingCurrency variable. Next, we get the current Currency and Date and store these values in __SalesCurrency and __SalesDate, respectively. Then, we get the sum of the amount of sales in R08_Sales and store that in the __SalesAmount variable. Now, we want to determine the date in our R08_Rates table so that we can use it as the effective date for our rate conversion, __ExchangeRateDate. To do this, we filter the R08_Rates table for all the values that have a To column value equal to our __ReportingCurrency variable, a From column value equal to our __SalesCurrency variable, and a Date column value that is less than or equal to our __SalesDate variable.
Then, we take the maximum value of the Date column for this filtered table using MAXX since we desire the most current exchange rate for each given sale. Once we know __ExchangeRateDate, we can use the same technique to calculate __ExchangeRate. However, first, we check to see whether __SalesCurrency and __ReportingCurrency are equal. If so, then __ExchangeRate should be 1. Otherwise, we calculate __ExchangeRate by essentially looking up the specified value in our R08_Rates table for the specified __ReportingCurrency, __SalesCurrency, and __ExchangeRateDate variables. Finally, we can RETURN our __SalesAmount multiplied by __ExchangeRate to return the __SalesAmount variable, which was converted into __ReportingCurrency.
The Reporting Amount Total measure addresses the common issue of measure totals in tables. The Reporting Amount Total measure uses HASONVALUE to determine whether the measurement context is an individual row within the table visualization or a total row. If it's an individual row, then the value to be displayed is simply the Reporting Amount measure. However, if the context is a total row, then the calculation summarizes the R08_Sales table by Date and Currency, adds Reporting Amount as the __Reporting Amount column, and then uses SUMX to sum the __Reporting Amount column.