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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
hperashmi83
Frequent Visitor

currency conversion

Need Urgent help for currency conversion. I have a table with bank balance in local currency and I need to convert the amount to USD. I also have exchange rate table which has exchange rate for multiple days... The conversion must happen based on latest date on the list.

Table1 

Statement DateCurrencyAmount in Local Currency
1/26/2022BRL800.00
1/12/2022EUR200.00
1/26/2022EUR1,800.00
1/26/2022SEK2,000.00
1/5/2022JPY4,250

 Table 2

From currencyTo-currencyValid fromExchan
   ge Rate
BRLUSD02.02.20225.3016
BRLUSD01.02.20225.2798
BRLUSD31.01.20225.30865
BRLUSD28.01.20225.4065
EURUSD02.02.20220.88527
EURUSD01.02.20220.88901
EURUSD31.01.20220.89194
EURUSD28.01.20220.89562
SEKUSD02.02.20229.20325
SEKUSD01.02.20229.2777
SEKUSD31.01.20229.3313
SEKUSD28.01.20229.4287
JPYUSD02.02.2022114.39
JPYUSD01.02.2022114.785
JPYUSD31.01.2022115.23
JPYUSD28.01.2022115.185

 

expected result = 

Statement DateCurrencyAmount in Local CurrencyAmount in USD
1/26/2022BRL800.00800.00 *5.3016 =4241.28
1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @hperashmi83 ,

You can modify your table1 query like this in Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ3MtM3MjAyUtJRcgryAZIWBgZ6BgZKsTogSUMjmKRraBCQNEKWROiESBrqWGCXDnb1BunVMUCWNoXJegVEAkkTHSNToFQsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Statement Date" = _t, Currency = _t, #"Amount in Local Currency" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Statement Date", type date}, {"Currency", type text}, {"Amount in Local Currency", Int64.Type}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Currency"}, Table2, {"From currency"}, "Table2", JoinKind.LeftOuter),
    #"Added Custom" = Table.AddColumn(#"Merged Queries", "Amount in USD", each Table.Max([Table2],"Valid from")[Exchange Rate] * [Amount in Local Currency],type number),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Table2"})
in
    #"Removed Columns"

vyingjl_0-1644392605571.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
sajjadkhan25
Helper I
Helper I

Can you please share pbix if it's completed please

v-yingjl
Community Support
Community Support

Hi @hperashmi83 ,

You can modify your table1 query like this in Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ3MtM3MjAyUtJRcgryAZIWBgZ6BgZKsTogSUMjmKRraBCQNEKWROiESBrqWGCXDnb1BunVMUCWNoXJegVEAkkTHSNToFQsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Statement Date" = _t, Currency = _t, #"Amount in Local Currency" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Statement Date", type date}, {"Currency", type text}, {"Amount in Local Currency", Int64.Type}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Currency"}, Table2, {"From currency"}, "Table2", JoinKind.LeftOuter),
    #"Added Custom" = Table.AddColumn(#"Merged Queries", "Amount in USD", each Table.Max([Table2],"Valid from")[Exchange Rate] * [Amount in Local Currency],type number),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Table2"})
in
    #"Removed Columns"

vyingjl_0-1644392605571.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

serpiva64
Solution Sage
Solution Sage

Hi, 

i think there is an error in your exemple.

the change of 5.3016 for BRL is valid from 02/02/2022 but the bank balance is in date 1/26/2022 which is before.

please control your data to be sure to obtain the right result 

what ever date we receive the statement we want to convert that value with current Excahnge rate so we just have to pick the currency and amount from Table 1 and currency and excahnge rate from Table 2. So please help provide me a solution

Hi, this is the result:

serpiva64_0-1643987526341.png

To obtain it i create the following 2 query:

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ3MtM3MjAyUtJRcgryAZIWBgZ6BgZKsTogSUMjmKRraBCQNEKWROiESBrqWGCXDnb1BunVMUCWNoXJegVEAkkTHSNToFQsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Statement Date" = _t, Currency = _t, #"Amount in Local Currency" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Statement Date", type text}, {"Currency", type text}, {"Amount in Local Currency", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type",",","",Replacer.ReplaceText,{"Amount in Local Currency"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",".",",",Replacer.ReplaceText,{"Amount in Local Currency"}),
#"Changed Type with Locale" = Table.TransformColumnTypes(#"Replaced Value1", {{"Statement Date", type date}}, "en-US"),
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type with Locale",{{"Amount in Local Currency", type number}}),
#"Sorted Rows" = Table.Sort(#"Changed Type1",{{"Statement Date", Order.Ascending}}),
#"Grouped Rows" = Table.Group(#"Sorted Rows", {"Currency"}, {{"Count", each _, type table [Statement Date=nullable date, Currency=nullable text, Amount in Local Currency=nullable number]}, {"Current", each List.Max([Statement Date]), type nullable date}}),
#"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"Statement Date", "Amount in Local Currency"}, {"Statement Date", "Amount in Local Currency"}),
#"Merged Queries" = Table.NestedJoin(#"Expanded Count", {"Currency"}, #"Table (2)", {"From currency"}, "Table (2)", JoinKind.LeftOuter),
#"Expanded Table (2)" = Table.ExpandTableColumn(#"Merged Queries", "Table (2)", {"Exchange rate"}, {"Exchange rate"}),
#"Added Custom" = Table.AddColumn(#"Expanded Table (2)", "Amount in USD", each [Amount in Local Currency]*[Exchange rate]),
#"Changed Type2" = Table.TransformColumnTypes(#"Added Custom",{{"Amount in USD", type number}})
in
#"Changed Type2"

 

and the second:

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bdExCsMwDIXhu3gOxk+yY2ktzdJ2KAkZSsj9r1Gn7VBZAWMs+BA/eNvCZX6EIazLtd2JYjuUiNpQIieMYR86A2OoqjjDzeB/j4zFIRKDcvqZaZ3Pg1IUKVQ9Qoc0wSGT1JBCs0Mm6UBlpA9apvt5k7YHU/EIFtVanTFJGpnBzpgijZnku+f2fJ0HATmyeoPOVCkOmSCgfS47Y4IOg2PR/gY=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"From currency" = _t, #"To-currency" = _t, #"Valid from" = _t, #"Exchange rate" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Valid from", type date}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type",".",",",Replacer.ReplaceText,{"Exchange rate"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Replaced Value",{{"Exchange rate", type number}}),
#"Grouped Rows" = Table.Group(#"Changed Type1", {"From currency"}, {{"Count", each _, type table [From currency=nullable text, #"To-currency"=nullable text, Valid from=nullable date, Exchange rate=nullable number]}, {"Current", each List.Max([Valid from]), type nullable date}}),
#"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"To-currency", "Valid from", "Exchange rate"}, {"To-currency", "Valid from", "Exchange rate"}),
#"Added Conditional Column" = Table.AddColumn(#"Expanded Count", "Custom", each if [Valid from] = [Current] then [Exchange rate] else null),
#"Filtered Rows" = Table.SelectRows(#"Added Conditional Column", each ([Custom] <> null))
in
#"Filtered Rows"

 

Some steps are not necessary for you because i needed to transform date and number to local.

 

If this post isuseful to help you to solve your issue consider giving the post a thumbs up and accepting it as a solution !

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors