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
geemian93
Frequent Visitor

Creating a Relationship with duplicate values in power Query in Excel

Hello There,

I have two tables, 1. Transaction Table and 2. Exchange Rate Table as below.

The transaction table records the daily transaction in multiple currecnies while the exchange rate table contain the daily exchange rates.

I wanted to convert the amounts from trsasaction table multipled by the exchange rates as per the currency column and as per date but both table consist multple transactions and exchange rates at multiple dates it doesn't allow to craete relationship. I had tried creating "Bridge Table" for Date and Currency Code, however it still doesn't work.


Transaction Table:

DateDoc No.AmountTrans. Currency

1/1/202310000251250USD
5/1/20231000030200USD
9/1/20231000050100USD
10/1/20231000100350USD

Exchange Rate Table:

Daterep. CurrencyUSD/EUR Rate

1/1/2023EUR0.95000
1/2/2023EUR0.95125
1/3/2023EUR0.92654
1/4/2023EUR0.95784
1/5/2023EUR0.95789
1/6/2023EUR0.95700
1/7/2023EUR0.95450
1/8/2023EUR0.94975
1/9/2023EUR0.95251
1/10/2023EUR0.95400
So on:------

 

The desired results should be as follows:
DateDoc No. AmountCurrencyUSD/EUR RateEUR Amount

1/1/202310000251250USD0.950001187.5
5/1/20231000030200USD0.95789191.58
9/1/20231000050100USD0.9525195.25
10/1/20231000100350USD0.95400333.90
2 ACCEPTED SOLUTIONS
dufoq3
Super User
Super User

Hi @geemian93, with your's sample data it is simple (but you have probably different data)

 

Result

dufoq3_0-1719404001670.png

let
    TransactionTable = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMDJW0lEyNAACI1MQy8jUAEiFBrsoxepEK5miqTEGSRoZICuxRFMC1m+IosTQAFUNRNYYYVMsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DateDoc = _t, #"No." = _t, #"AmountTrans." = _t, Currency = _t]),
    ExchRateTable = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc7BDcAgCAXQXTibCghaBugCTXoy7r9Ga4K94IXLy//83oEyZUYukOB67u/iYYqIMNJEjkisjiUgVxVHicl2LtQdmmPd4D+oRRRdeAYUa2utxSQrORJueufT8QI=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Daterep." = _t, Currency = _t, #"CurrencyUSD/EUR Rate" = _t]),
    TransactionTableChangedType = Table.TransformColumnTypes(TransactionTable,{{"No.", Int64.Type}, {"AmountTrans.", type number}, {"DateDoc", type date}}, "sk-SK"),
    ExchRateTableChangedType = Table.TransformColumnTypes(ExchRateTable,{{"Daterep.", type date}, {"CurrencyUSD/EUR Rate", type number}}, "en-US"),
    MergedQueries = Table.NestedJoin(TransactionTableChangedType, {"DateDoc"}, ExchRateTableChangedType, {"Daterep."}, "ExchRateTableChangedType", JoinKind.LeftOuter),
    #"Expanded ExchRateTableChangedType" = Table.ExpandTableColumn(MergedQueries, "ExchRateTableChangedType", {"CurrencyUSD/EUR Rate"}, {"CurrencyUSD/EUR Rate"})
in
    #"Expanded ExchRateTableChangedType"

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

AlienSx
Super User
Super User

Make sample tables with multi currency transactions and rates together with resulting table. Now it works for single ccy pair. 

let
    combine = transactions & Table.RenameColumns(rates, {"Daterep.", "Date"}),
    sort = Table.Sort(combine,{{"Date", Order.Ascending}, {"Doc No.", Order.Ascending}}),
    rate_down = Table.FillDown(sort,{"USD/EUR Rate"}),
    filter = Table.SelectRows(rate_down, each ([Currency] = "USD")),
    amount = Table.AddColumn(filter, "EUR Amount", each [#"AmountTrans."] * [#"USD/EUR Rate"])
in
    amount

View solution in original post

2 REPLIES 2
AlienSx
Super User
Super User

Make sample tables with multi currency transactions and rates together with resulting table. Now it works for single ccy pair. 

let
    combine = transactions & Table.RenameColumns(rates, {"Daterep.", "Date"}),
    sort = Table.Sort(combine,{{"Date", Order.Ascending}, {"Doc No.", Order.Ascending}}),
    rate_down = Table.FillDown(sort,{"USD/EUR Rate"}),
    filter = Table.SelectRows(rate_down, each ([Currency] = "USD")),
    amount = Table.AddColumn(filter, "EUR Amount", each [#"AmountTrans."] * [#"USD/EUR Rate"])
in
    amount
dufoq3
Super User
Super User

Hi @geemian93, with your's sample data it is simple (but you have probably different data)

 

Result

dufoq3_0-1719404001670.png

let
    TransactionTable = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMDJW0lEyNAACI1MQy8jUAEiFBrsoxepEK5miqTEGSRoZICuxRFMC1m+IosTQAFUNRNYYYVMsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DateDoc = _t, #"No." = _t, #"AmountTrans." = _t, Currency = _t]),
    ExchRateTable = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc7BDcAgCAXQXTibCghaBugCTXoy7r9Ga4K94IXLy//83oEyZUYukOB67u/iYYqIMNJEjkisjiUgVxVHicl2LtQdmmPd4D+oRRRdeAYUa2utxSQrORJueufT8QI=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Daterep." = _t, Currency = _t, #"CurrencyUSD/EUR Rate" = _t]),
    TransactionTableChangedType = Table.TransformColumnTypes(TransactionTable,{{"No.", Int64.Type}, {"AmountTrans.", type number}, {"DateDoc", type date}}, "sk-SK"),
    ExchRateTableChangedType = Table.TransformColumnTypes(ExchRateTable,{{"Daterep.", type date}, {"CurrencyUSD/EUR Rate", type number}}, "en-US"),
    MergedQueries = Table.NestedJoin(TransactionTableChangedType, {"DateDoc"}, ExchRateTableChangedType, {"Daterep."}, "ExchRateTableChangedType", JoinKind.LeftOuter),
    #"Expanded ExchRateTableChangedType" = Table.ExpandTableColumn(MergedQueries, "ExchRateTableChangedType", {"CurrencyUSD/EUR Rate"}, {"CurrencyUSD/EUR Rate"})
in
    #"Expanded ExchRateTableChangedType"

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

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.