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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Column merge Help !!!!

Good morning all !

 

I would like your help on a problem that I have been encountering for weeks!

I will explain my situation to you very quickly:

 

In my Power Bi report, I have two tables:

 

  1. A "DAD Factory" table
  2. A"Master table" table

 

In my "DAD factory" table I have 3 columns:

  • "Material Code"
  • "Extraction date" 
  • "ADI number" 

It should be noted that there are several duplicates in this table.
For example a material code can have several ADI Number and several extraction date:

Here's a quick example (in red you can see the duplicates😞

 

Extraction date (A column with duplicate rows)Material Code (A column with duplicate rows)ADI number (A column with unique data)
01/01/2020 (always the date of the first of the month)3612620115/12/25
01/02/2020361262253511/12/27
01/03/2020361262234534414/12/29
01/01/20203612620118/12/86
01/04/2020362519/30/56

Dad Factory.png
in my Master table I have three columns:

  • "Extaction Date"
  • "Material code" 
  • "Quantity"

I also wish to specify that in this table I also have several duplicates (in red you can see the duplicates).

here is a quick example:

 

Extraction date (A column with duplicate rows)Material Code (A column with duplicate rows)Quantity
01/01/2020 (always the date of the first of the month)36126201200
01/02/20203612622535300
01/03/20203612622345344400
01/01/202036126201740

 

 

Master tabel.png
What I'm trying to do is to be able to extract the set of ADI numbers from the "DAD Factory" table which are linked to a material code and to link it to the matarial code of the Master table (like a VLOOKUP in Excel).

So I tried to merge the two tables, but as there are duplicates in each table, this recreate new duplicates in my master table

 

Can someone help me?

1 ACCEPTED SOLUTION

Hello @Anonymous 

 

then I would appreciate if you could mark my post as solution. 

About your other question... what you mean duplicates... you a line with date, material and ADI where in the ADI-column you have two time a ADI-number? Then use this code (not tested)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc1LCsAgDIThu2QtJJkkVs8i3v8aPgqWlsIsZvHB3xqJ8hwEQoksKzJE59VgBSOopxvhjRAWi+lm12H2YeZh7kv6lvXI32pZqOSD/EHYvcomHBP0AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Extraction date" = _t, #"Material Code" = _t, #"ADI number" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Extraction date", type date, "en-US"}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Extraction date", "Material Code"}, {{"AllADI", each Text.Combine(List.Distinct(_[ADI number]), ", "), type text}})
in
    #"Grouped Rows"

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@Jimmy801 

 

you are a monster, you are too strong your solution works !! 🤗

I just have a quick question, do you know a way to remove duplicates that may appear in the "ALLADI" column

 

thank you for your help !

Hello @Anonymous 

 

then I would appreciate if you could mark my post as solution. 

About your other question... what you mean duplicates... you a line with date, material and ADI where in the ADI-column you have two time a ADI-number? Then use this code (not tested)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc1LCsAgDIThu2QtJJkkVs8i3v8aPgqWlsIsZvHB3xqJ8hwEQoksKzJE59VgBSOopxvhjRAWi+lm12H2YeZh7kv6lvXI32pZqOSD/EHYvcomHBP0AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Extraction date" = _t, #"Material Code" = _t, #"ADI number" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Extraction date", type date, "en-US"}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Extraction date", "Material Code"}, {{"AllADI", each Text.Combine(List.Distinct(_[ADI number]), ", "), type text}})
in
    #"Grouped Rows"

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

you can manipulate your DAD-table in a way that you don't have any duplicates anymore. Group material and date and use Text.Combine to concatenate your ADI-numbers. After this is done you can join your DAD-table to your master table by date and material number and no row will be duplicated. Hope I was clear 🙂

Here an example

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc1LCsAgDIThu2QtJJkkVs8i3v8aPgqWlsIsZvHB3xqJ8hwEQoksKzJE59VgBSOopxvhjRAWi+lm12H2YeZh7kv6lvXI32pZqOSD/EHYvcomHBP0AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Extraction date" = _t, #"Material Code" = _t, #"ADI number" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Extraction date", type date, "en-US"}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Extraction date", "Material Code"}, {{"AllADI", each Text.Combine(_[ADI number], ", "), type text}})
in
    #"Grouped Rows"

Outcome

Jimmy801_0-1613472210332.png

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

 

 

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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