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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Spotto
Helper IV
Helper IV

Look for several codes of the same row in another table

Hi everyone, I need some help. I have a table A with many codes separated by ( ; ) on the same row.
I would like to look up each code by line in another table B where the codes are individual and return a value

 

Ex.:

TABLE A

COD

1234;45;33

23;875;

23

 

-------------------------------

 

TABLE B

COD       VALUE

123          34,34

23            123,99

33            234,55

875          123,44

 

tks for help me

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @Spotto ,

 

In Power Query, add a new column in TableA like this:

 

Text.Split([COD], ";")

 

 

Expand this column to new rows and you will have single values to compare/merge to from TableB.

If you need a single row per transaction/dimension in tableA, then just group the table after your merge and sum your value field.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

2 REPLIES 2
AnkitKukreja
Super User
Super User

Hi! @Spotto 

 

Please try the below code and paste in the advance editor of your blank query and your Table A would look like table B (see below). Let me know if it helps or if you need anything else.

 

AnkitKukreja_0-1642150044569.png

 

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNrE2MbU2NjYytrYwN7U2MlaKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [COD = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"COD", type text}}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "COD", Splitter.SplitTextByDelimiter(";", QuoteStyle.None), {"COD.1", "COD.2", "COD.3", "COD.4", "COD.5"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"COD.1", Int64.Type}, {"COD.2", Int64.Type}, {"COD.3", Int64.Type}, {"COD.4", Int64.Type}, {"COD.5", Int64.Type}}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {}, "Attribute", "Value"),
#"Removed Columns" = Table.RemoveColumns(#"Unpivoted Columns",{"Attribute"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Value", "Cod"}})
in
#"Renamed Columns"

  

For Power BI trainings or support dm or reach out to me on LinkedIn.
If my response has successfully addressed your question or concern, I kindly request that you mark this post as resolved. Additionally, if you found my assistance helpful, a thumbs-up would be greatly appreciated.

Thanks,
Ankit Kukreja
www.linkedin.com/in/ankit-kukreja1904
BA_Pete
Super User
Super User

Hi @Spotto ,

 

In Power Query, add a new column in TableA like this:

 

Text.Split([COD], ";")

 

 

Expand this column to new rows and you will have single values to compare/merge to from TableB.

If you need a single row per transaction/dimension in tableA, then just group the table after your merge and sum your value field.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Solution Authors
Top Kudoed Authors