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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Zosy
Helper II
Helper II

Dynamic currency exchange based on currency selected by the user

Hi,

 

I am trying to build a dashboard where the user would choose the currency for the sales from a slicer. Based on this selection, the base amount of the invoices expressed in SEK would get converted to their specified currency using the corresponding conversion rates (by year and currency).

 

If the end user would choose EUR from the slicer, in 2022 the amount should be  1500 SEK * 0.6744 = 1,011.6 EUR  and so on. How can I achive it?

present case.JPG

Desired outcome:

 

YearTotal Sales
2019809.28
20201686
20211449.96
20221011.6

 

 

 

DATA USED

 

Invoices

 

Invoice NumberDateAmount (SEK)
115-Sep-2021100
225-Jan-2019200
36-Jan-2019500
422-Mar-2020900
522-Apr-2022300
615-Sep-2022800
725-Jan-20201300
87-Jan-2019500
920-Mar-20212000
1010-Apr-2022400
1115-Sep-2020300
1220-Jan-202150

 

 

Currency Rates

 

exchangerateyearcurrency_namecurrency_code
0.65352019EuroEUR
0.57812019Pound SterlingGBP
0.77182019US DollarUSD
0.59012020Pound SterlingGBP
0.67312020EuroEUR
0.75362020US DollarUSD
0.65382021EuroEUR
0.74552021US DollarUSD
0.58142021Pound SterlingGBP
0.67442022EuroEUR
0.57982022Pound SterlingGBP
0.79782022US DollarUSD

 

Thank you.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Zosy , this can be done by creating these two measures:

 

Total Amount (SEK) = SUM('Invoices'[Amount (SEK)])
Total Sales (in selected currency) = 
    SUMX(
        VALUES('Invoices'[Date].[Year]),
        VAR vExchangeRate = 
            LOOKUPVALUE(
                'CurrencyRates'[exchangerate],
                CurrencyRates[currency_code], SELECTEDVALUE('CurrencyRates'[currency_code]),
                CurrencyRates[year], 'Invoices'[Date].[YEAR]
            )
        RETURN
            [Total Amount (SEK)] * vExchangeRate
    )

 

This gives me these results:

EylesIT_0-1656953515851.png

YearTotal Sales (in selected currency)currency_code
2019784.2EUR
2019693.72GBP
2019926.16USD
20201682.75EUR
20201475.25GBP
20201884USD
20211405.67EUR
20211250.01GBP
20211602.825USD
20221011.6EUR
2022869.7GBP
20221196.7USD

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@Zosy , this can be done by creating these two measures:

 

Total Amount (SEK) = SUM('Invoices'[Amount (SEK)])
Total Sales (in selected currency) = 
    SUMX(
        VALUES('Invoices'[Date].[Year]),
        VAR vExchangeRate = 
            LOOKUPVALUE(
                'CurrencyRates'[exchangerate],
                CurrencyRates[currency_code], SELECTEDVALUE('CurrencyRates'[currency_code]),
                CurrencyRates[year], 'Invoices'[Date].[YEAR]
            )
        RETURN
            [Total Amount (SEK)] * vExchangeRate
    )

 

This gives me these results:

EylesIT_0-1656953515851.png

YearTotal Sales (in selected currency)currency_code
2019784.2EUR
2019693.72GBP
2019926.16USD
20201682.75EUR
20201475.25GBP
20201884USD
20211405.67EUR
20211250.01GBP
20211602.825USD
20221011.6EUR
2022869.7GBP
20221196.7USD

 

 

Thank you for your help! This worked easily with my data set.

tamerj1
Super User
Super User

Hi @Zosy 

best and easiest method is to create a date table that contains the date and the year. Connect the date with the invoiced table and connect the year with currency exchange table. Then you measure would be

SUM ( Invoices[Amount (SEK)] ) * SELECTEVALUE ( 'Currency Rates'[exchangerate] )

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.