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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Swapnil_
Regular Visitor

Power Query: Split single row into multiple Rows

I have one row Suppose Row number 21 for which two values are present in column A , Two values in column B ,  Values are seperated by space in both columns and one value in Column C. I want to replace the single row by two rows.. how to do that in power query?

1 ACCEPTED SOLUTION

Hi, I've asked for sample data in usable format and expected result based on sample data. In future - if you'll ask for help - be so kind and read other users comments please.

 

Before

dufoq3_0-1721287597622.png

 

After

dufoq3_1-1721287614166.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSkxUSAQCJR2lxKTkFCiVqhSrE62UlKSQBAQxeVAGULKisiomD0hAmIVgdqFSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    Ad_Helper = Table.AddColumn(Source, "Helper", each 
        [ a = Record.ToList(_),
          b = if List.Contains(a, "#(lf)", (x,y)=> Text.Contains(x, y)) then List.Transform(List.Zip(List.Transform(a, (x)=> Text.Split(x, "#(lf)"))), (y)=> Text.Combine(y, "||"))  else {Text.Combine(a, "||")}
        ][b], type list ),
    RemovedOtherColumns = Table.SelectColumns(Ad_Helper,{"Helper"}),
    ExpandedHelper = Table.ExpandListColumn(RemovedOtherColumns, "Helper"),
    SplitColumnByDelimiter = Table.SplitColumn(ExpandedHelper, "Helper", Splitter.SplitTextByDelimiter("||", QuoteStyle.Csv)),
    RestoreNamesAndTypes = Value.ReplaceType(SplitColumnByDelimiter, Value.Type(Source))
in
    RestoreNamesAndTypes

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

7 REPLIES 7
Swapnil_
Regular Visitor

@Anonymous  @AlienSx @dufoq3 

 

Please find the below screenshot, In first column I have employee Name, but for few records I am getting two values, the values may or may not be duplicate. so I want to create seperate record for second occurance..In this case 2 employee name but they will have same employee Id( As there is financial figure associated with it)...

Swapnil__0-1721284010980.png

 

Hi, I've asked for sample data in usable format and expected result based on sample data. In future - if you'll ask for help - be so kind and read other users comments please.

 

Before

dufoq3_0-1721287597622.png

 

After

dufoq3_1-1721287614166.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSkxUSAQCJR2lxKTkFCiVqhSrE62UlKSQBAQxeVAGULKisiomD0hAmIVgdqFSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    Ad_Helper = Table.AddColumn(Source, "Helper", each 
        [ a = Record.ToList(_),
          b = if List.Contains(a, "#(lf)", (x,y)=> Text.Contains(x, y)) then List.Transform(List.Zip(List.Transform(a, (x)=> Text.Split(x, "#(lf)"))), (y)=> Text.Combine(y, "||"))  else {Text.Combine(a, "||")}
        ][b], type list ),
    RemovedOtherColumns = Table.SelectColumns(Ad_Helper,{"Helper"}),
    ExpandedHelper = Table.ExpandListColumn(RemovedOtherColumns, "Helper"),
    SplitColumnByDelimiter = Table.SplitColumn(ExpandedHelper, "Helper", Splitter.SplitTextByDelimiter("||", QuoteStyle.Csv)),
    RestoreNamesAndTypes = Value.ReplaceType(SplitColumnByDelimiter, Value.Type(Source))
in
    RestoreNamesAndTypes

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

hi @dufoq3, thank you for the solution.. It was first time I was looking for help in community..for sure I provide data in case I need any help

You're welcome.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

AlienSx
Super User
Super User

grabbed data from @Anonymous 's post

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKkvMKU01VABTRko6EL4xhG8C45sqxepAlZpBpMxhUhYQviWMb2igFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ColumnA = _t, ColumnB = _t, ColumnC = _t]),
    to_list = Table.ToList(
        Source, 
        (w) => List.TransformMany(
            {w}, 
            (x) => List.Zip({Text.Split(x{0}, " "), Text.Split(x{1}, " ")}),
            (x, y) => y & {x{2}}
        )
    ),
    to_tbl = Table.FromList(List.Combine(to_list), (x) => x, Table.ColumnNames(Source))
in
    to_tbl
Anonymous
Not applicable

Hi @Swapnil_ ,

 

Like this?

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKkvMKU01VABTRko6EL4xhG8C45sqxepAlZpBpMxhUhYQviWMb2igFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ColumnA = _t, ColumnB = _t, ColumnC = _t]),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {}, "Attribute", "Value"),
    Custom1 = Table.TransformColumns(#"Unpivoted Columns",{"Value", each Text.Split(_, " ")} ),
    #"Expanded Value" = Table.ExpandListColumn(Custom1, "Value"),
    #"Grouped Rows" = Table.Group(#"Expanded Value", {"Attribute"}, {{"Data", each _[Value]}}),
    Custom2 = Table.FromColumns(#"Grouped Rows"[Data],#"Grouped Rows"[Attribute])
in
    Custom2

 If I've misunderstood your needs, could you tell me what your expected output is?

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

dufoq3
Super User
Super User

Provide sample data in usable format and expected result based on that. Thanks.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.