Forum Discussion

Florex's avatar
Florex
Frequent Visitor
2 years ago
Solved

Duplicate Record and change one value

Hello kind community!

 

I want to duplicate any record in my dataset and want change one value (due to multiple relationship is not possible)

 

How is currently looks:

 

ProductIDold_ID
Cola123ABC
Fanta888DEF
Sprite777GHF

 

 

What it should look like:

 

ProductIDold_ID
Cola

123

ABC
ColaABCABC
Fanta888DEF
FantaDEFDEF
Sprite777GHF
SpriteGHF

GHF

 

 

Background: Want to use ID column for a relationship to other table and i need old and new identifier to find all processes 

 

Thank you

  • Hi Florex 

    You  can easily duplicate all rows of a table in the query editor by using Table.Repeat or by refererring to another t query for the list of IDs to be duplicated for selective duplication. But doing either will most likely result to a many-to-many relationship, the current table being on the many side.  Please see attached pbix for reference.

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Florex ,

    danextian Good Answer! And you can also achieve this by Unpivoted in Power Query:
    Duplicate the original table first:

    And in the new table Table(2), select column ID and old_ID and choose "Unpivot Only Selected Columns":

    Then choose "Merge Queries as New" in Table(2):

    The output is as below:

    Follow the diagram below to set up and delete the column Attribute:

    And the final output is as below:

     


    Best Regards,
    Dino Tao
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Hi Florex 

    You  can easily duplicate all rows of a table in the query editor by using Table.Repeat or by refererring to another t query for the list of IDs to be duplicated for selective duplication. But doing either will most likely result to a many-to-many relationship, the current table being on the many side.  Please see attached pbix for reference.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Florex ,

    danextian Good Answer! And you can also achieve this by Unpivoted in Power Query:
    Duplicate the original table first:

    And in the new table Table(2), select column ID and old_ID and choose "Unpivot Only Selected Columns":

    Then choose "Merge Queries as New" in Table(2):

    The output is as below:

    Follow the diagram below to set up and delete the column Attribute:

    And the final output is as below:

     


    Best Regards,
    Dino Tao
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.