Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Exchange Rate Conversion with Date Range

Hey Everyone, 

I need to convert the value of revenue (total_revenue_usd in finance table) into other currencies (exchange_rate table). If the transaction took place '6/1/2022', it must be converted at the exchange rate of that day. The user can choose the type of currency (name in exchange_rate table), using the dropdown and in addition with the slicer the date range (baseline_date) when the sale took place - it can be just one day or several days.

wcaleniewiola_0-1658411285046.png

 

Currently I've managed to do it in such a way that it works for a single day, but if I select a range of several days, it recalculates the value of the revenue based on the exchange rate of the last day selected in slicer. What I want is to recalculate each day separately at a given rate and then sum up the revenue value.

My data model without sensitive data:

wcaleniewiola_0-1658412315852.png

I have the following metrics in my measure table:

 

Converted_Revenue = 
VAR _Date = [Currency_Date]
VAR _CurrencySelected = [Currency_Selected]
VAR _Revenue = Measure_Table[Revenue]
VAR _Rate = LOOKUPVALUE(exchange_rates_query[usd_exchange_rate], 
                        exchange_rates_query[name], _CurrencySelected, 
                        exchange_rates_query[day], _Date)
VAR _ConvertedMeasure = _Revenue / _Rate

RETURN
_ConvertedMeasure

 

where currency_date is max(dim_date(day)) and currency_selected = SELECTEDVALUE(Dim_Currency_Names[currency]).

Any help would be appreciated. Thanks!

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Try

Converted Revenue =
SUMX (
    'Finance query',
    VAR currentDate = 'Finance query'[day]
    VAR chosenCurrency = [Currency Selected]
    VAR exchRate =
        LOOKUPVALUE (
            exchange_rates_query[usd_exchange_rate],
            exchange_rates_query[name], chosenCurrency,
            exchange_rates_query[day], currentDate
        )
    RETURN
        'Finance query'[total_revenue_usd] * exchRate
)

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

It worked! Many thanks!

johnt75
Super User
Super User

Try

Converted Revenue =
SUMX (
    'Finance query',
    VAR currentDate = 'Finance query'[day]
    VAR chosenCurrency = [Currency Selected]
    VAR exchRate =
        LOOKUPVALUE (
            exchange_rates_query[usd_exchange_rate],
            exchange_rates_query[name], chosenCurrency,
            exchange_rates_query[day], currentDate
        )
    RETURN
        'Finance query'[total_revenue_usd] * exchRate
)

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.