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
JenWilson
Advocate I
Advocate I

Duplicate rows in a table based on details of another column

Hi, 

I would like to (hopefully) just add rows to the existing table "Production Data". 

 

In the table below, the first 3 columns represent existing content while the last 3 columns represent how I would like the outcome of my request to look.

 

My goal is to duplicate any row where the Product Code column is "AB". The duplicate row would then modify the Department Column data to say "Sanding". In essance, there are 2 departments that worked on the same "product code" item and we need to account for that work across both department. 

 

So the formula would need to look for the specified Product Code "AB" and if found add a row matching all row content but change the Department column to "Sanding".  If any other Product Code is in the Product Code column, it would just keep the one row. 

 

Something as simple as this perhaps?

IF [Product Code] = "AB", then duplicate row but change [Department], "Sanding" 

Product CodeDepartmentquantity Product CodeDepartmentquantity
ABWelding10 ABWelding10
ABWelding20 ABWelding20
ABWelding30 ABWelding30
ABWelding40 ABWelding40
ABWelding50 ABWelding50
ABWelding60 ABWelding60
CDWelding100 ABSanding10
CDWelding100 ABSanding20
CDWelding100 ABSanding30
CDWelding100 ABSanding40
    ABSanding50
    ABSanding60
    CDWelding100
    CDWelding100
    CDWelding100
    CDWelding100

 

6 REPLIES 6
alekhved
Resolver I
Resolver I

hi @JenWilson ,

 

Here you go. ( Power Query Editor)

 

Step 1 : Create a duplicate table with the same data. Right click on exisiting table, click on duplicate. 

 

Step 2 : Filter the data in new table based on Prodcut Code = AB

 

Step 3 : Replace the value from Welding to Sanding

 

Step 4 : Click on original table, Go to Home -> Append Queries -> Append Queries as New. Select Both the table and in the end you would have one more table with expected rows.

 

Table 1 :

alekhved_0-1673985573141.png

 

Table 2

alekhved_1-1673985603869.png

 

 

 

 

Thanks!

@alekhved , will these steps ensure any newly added data will be addressed in the same way? There are multiple entries coming in daily for these product codes. Thanks! 

 

@JenWilson Another way to achieve this is,

 

  • Add a table with Product Code and Department

SivaMani_0-1673986162603.png

  • Use Merge Queries[Left Outter] - New table <- Existing table

SivaMani_1-1673986332466.png

 

  • Expand the columns
    SivaMani_2-1673986371503.png

SivaMani_3-1673986407871.png

 

You can use the New table as a control table and maintain your combinations.

 

This option doesn't seem feasable, as there are hundreds of product codes that I would need to add to the additional table. 

hi @JenWilson 

 

That can be done too. In the Advance Editor of Table (2), Change the source defintion as 

 

Source = #"Table",

 

(here the  Table  is the original name of the table that you want to replicate)

 

Thanks!

  Unfortunately, I don't think this solution will work as the source is SQL code and it didn't like the # placement. 

 

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.