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
PaulinePitt
New Member

Create duplicate row based on value, but change contents in 2 of the cells in new duplicate row

I need to create a new row in each instance where [split user] is not blank.  Then I need to replace contents in [assigned] with contents in [split user], replace contents in [split user] with “Y".  Is this possible?  Thank you for your help!!!
 
Existing TableScreen Shot 2019-10-08 at 6.11.07 AM.png
 
 
 
 
 
 
New Data Table
If [split user] is not blank, duplicate row, replace contents in [assigned] with contents in [split user], replace contents in [split user] with “Y"Screen Shot 2019-10-08 at 6.13.43 AM.png
 
1 ACCEPTED SOLUTION
v-lid-msft
Community Support
Community Support

Hi @PaulinePitt ,

 

We can meet your requirement in the Power Query Editor, following is the M Query

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwtNQ3NNA3UtJRCoFiIAoGYnelWB2EAkOgSBAUg2R9QTiZHCWOUAxELqjWWOobGwBFvKAYaoyRhZlSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"created at " = _t, #"created by " = _t, assigned = _t, #"split user" = _t, #"buddy rehash" = _t, store = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"created at ", type date}, {"created by ", type text}, {"assigned", type text}, {"split user", type text}, {"buddy rehash", type text}, {"store", type text}}),
    #"New Table" = Table.SelectRows(#"Changed Type",each Text.Trim([split user]) <> ""),
    #"Renamed Columns" = Table.RenameColumns(#"New Table",{{"split user", "assigned"}, {"assigned", "split user"}}),
    #"Append Query" = Table.Combine({#"Changed Type",#"Renamed Columns"}),
    #"Added Custom" = Table.AddColumn(#"Append Query", "Custom", each if Text.Trim([split user]) <> "" then "Y" else ""),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"split user"}),
    #"Renamed Columns1" = Table.RenameColumns(#"Removed Columns",{{"Custom", "split user"}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns1",{"created at ", "created by ", "assigned", "split user", "buddy rehash", "store"})
in
    #"Reordered Columns"

1. create a new table use selectrow function, then change the name of assigned and split user column

 

16.PNG17.PNG

 

2. append the new table step by the origin table step

 

18.PNG

 

3. add a new column to replace value in split user into Y

 

19.PNG

 

4. remove unnessary column and reorder the column

 

20.PNG

 

 


BTW, pbix as attached.

 

Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-lid-msft
Community Support
Community Support

Hi @PaulinePitt ,


How about the result after you follow the suggestions mentioned in my original post?Could you please provide more details about it If it doesn't meet your requirement?

 

Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-lid-msft
Community Support
Community Support

Hi @PaulinePitt ,

 

We can meet your requirement in the Power Query Editor, following is the M Query

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwtNQ3NNA3UtJRCoFiIAoGYnelWB2EAkOgSBAUg2R9QTiZHCWOUAxELqjWWOobGwBFvKAYaoyRhZlSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"created at " = _t, #"created by " = _t, assigned = _t, #"split user" = _t, #"buddy rehash" = _t, store = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"created at ", type date}, {"created by ", type text}, {"assigned", type text}, {"split user", type text}, {"buddy rehash", type text}, {"store", type text}}),
    #"New Table" = Table.SelectRows(#"Changed Type",each Text.Trim([split user]) <> ""),
    #"Renamed Columns" = Table.RenameColumns(#"New Table",{{"split user", "assigned"}, {"assigned", "split user"}}),
    #"Append Query" = Table.Combine({#"Changed Type",#"Renamed Columns"}),
    #"Added Custom" = Table.AddColumn(#"Append Query", "Custom", each if Text.Trim([split user]) <> "" then "Y" else ""),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"split user"}),
    #"Renamed Columns1" = Table.RenameColumns(#"Removed Columns",{{"Custom", "split user"}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns1",{"created at ", "created by ", "assigned", "split user", "buddy rehash", "store"})
in
    #"Reordered Columns"

1. create a new table use selectrow function, then change the name of assigned and split user column

 

16.PNG17.PNG

 

2. append the new table step by the origin table step

 

18.PNG

 

3. add a new column to replace value in split user into Y

 

19.PNG

 

4. remove unnessary column and reorder the column

 

20.PNG

 

 


BTW, pbix as attached.

 

Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.