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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sgannon1
Frequent Visitor

Convert currency

I need to convert the 'amount' column in the below table to EUR (currency is GBP at the moment), and then to merge the table with another that is already in EURO. 

So far I have not been able to do this without returning errors. 

I have a currency conversion table (also below) that shows todays exchange rate, however I am unsure how to use the table to write a formula that will convert the amount.? Any help would be appreciated. 

gbp.PNG

 

 

xch.PNG

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

This will work if you get rid of all of your non-GBP exchange rates. Do you need those? If you do, sure some more DAX magic can get you there.

 

Column = LOOKUPVALUE(ExchangeRates[ExchangeRate],ExchangeRates[CurrencyCode],"GBP",ExchangeRates[StartTime],MAX(ExchangeRates[StartTime]))

Oh wait, here is the additional DAX magic that will let you keep your other currency codes.

 

Column = LOOKUPVALUE(ExchangeRates[ExchangeRate],ExchangeRates[CurrencyCode],"GBP",ExchangeRates[StartTime],CALCULATE(MAX(ExchangeRates[StartTime]),ExchangeRates[CurrencyCode]="GBP"))

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

9 REPLIES 9
v-haibl-msft
Employee
Employee

@sgannon1

 

The solution provided by @Greg_Deckler should work. And you can also try with following column formula.

Converted Amount_Column = 
VAR LatestDate =
    CALCULATE (
        MAX ( 'Currency Conversion'[Starting Date] ),
        'Currency Conversion'[Currency Code] = "GBP"
    )
RETURN
    (
        CALCULATE (
            VALUES ( 'Currency Conversion'[1.2 Exchange Rate Amount] ),
            FILTER (
                'Currency Conversion',
                'Currency Conversion'[Currency Code] = "GBP"
                    && 'Currency Conversion'[Starting Date] = LatestDate
            )
        )
            * Table1[1.2 Amount]
)

Best Regards,
Herbert

Greg_Deckler
Super User
Super User

This will work if you get rid of all of your non-GBP exchange rates. Do you need those? If you do, sure some more DAX magic can get you there.

 

Column = LOOKUPVALUE(ExchangeRates[ExchangeRate],ExchangeRates[CurrencyCode],"GBP",ExchangeRates[StartTime],MAX(ExchangeRates[StartTime]))

Oh wait, here is the additional DAX magic that will let you keep your other currency codes.

 

Column = LOOKUPVALUE(ExchangeRates[ExchangeRate],ExchangeRates[CurrencyCode],"GBP",ExchangeRates[StartTime],CALCULATE(MAX(ExchangeRates[StartTime]),ExchangeRates[CurrencyCode]="GBP"))

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

I've a similar problem, in my case with nominal to constant currency....
anyway, in the proposed solution there are using the latest available exchange rate (MAX(StartTime))... i'm using it and it works fine, but can I make an slicer or use another pickable menu to change the date of the exchange rate used? What if I wish to know the price in GBP of March 1 2017?

Thanks

Hi @Greg_Deckler, @v-haibl-msft,

 

I'm struggling with a solution that converts each invoce to another currency based on the invoice date. I just can not find a solution here in the Community for that approach.

 

Could you please advise?

 

Thanks,

 

Fernando

calerof
Impactful Individual
Impactful Individual

Finally with the help of @EnterpriseDNA's video I could have the sales data converted from MXP to USD with the following code:

Sales in USD = SUMX( NetSales, 
                                   DIVIDE(
                                              NetSales[LineTotal],
                                              LOOKUPVALUE( ORTT[Rate], 
                                                ORTT[RateDate], VentasNetas[OINV.DocDate],
                                                ORTT[Currency], "USD" )
                                   )
                           )

where:

NetSales in the sales fact table,

ORTT includes the MXP/USD exchange rate by date.

 

I post this if it could be of any help.

 

Regards,

 

Fernando

 

@calerof - Can you provide example/sample source data and expected output?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hello @Greg_Deckler,

 

Sorry for not answering before, my client started requesting things afar from the agreement. 

 

The data are as follows:

 

Fact Table with sales by invoice line:

https://www.dropbox.com/s/hz5nc6kqda4wbv9/Daily%20Revenue%20by%20invoice%20item%20Original.xlsx?dl=0

 

Exchange rate table:

 

DateUSD
01-ene-1919.6512
02-ene-1919.6512
03-ene-1919.5878
04-ene-1919.6073
05-ene-1919.6073
06-ene-1919.6073
07-ene-1919.4902
08-ene-1919.3479
09-ene-1919.3479
10-ene-1919.2456
11-ene-1919.1236
12-ene-1919.1236
13-ene-1919.1236
14-ene-1919.1236
15-ene-1919.0064

 

In excel I would do it just easily with =vlookup convert all sales in MXP to USD based on the invoice date and bring the sales already in USD to the same column to have a total in USD, e.g.

https://www.dropbox.com/s/jvwex5u8o0l7mo9/Daily%20Revenue%20by%20invoice%20item.xlsx?dl=0

 

In this way the last column would show Sales in USD converted at the invoice date, not at month end.

 

When I use LOOUPVALUE my problem is when assigning the current date in SEARCH VALUE doesn't recognize the row context and get the error: "A table of multiple values was supplied where a single value was expected".

 

LOOKUPVALUE (
    EXCHANGERATES[RATE],
    EXCHANGERATES[DATE], DATE ( 2019, 1, 12 ),
    EXCHANGERATES[CURRENCY], "MXP"
)
 
Could you please advice?
 
Thanks a lot,
 
Fernando
 
calerof
Impactful Individual
Impactful Individual

Hi @Greg_Deckler,

 

So as you can see, my intent here is to be able to convert each individual invoice based on its date's exchange rate, not one final convertion at month end with only one exchange rate.

 

Could you advise on a way to do it?

 

Thank you for your help.

 

Fernando

calerof
Impactful Individual
Impactful Individual

Hello @Greg_Deckler,

 

Sorry to insist. I'd just only like to know if there is a way I can solve my problem of currency conversion in Power BI.

 

Thanks and regards,

 

Fernando

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors