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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How do I split each row into multiple rows?

Hi, 

 

I'm working with tables like this one, with a series of values in the same row: 

Alienvolm_1-1622550428935.png

 

How can I get Column2 split into a row for each value on a new line? Ideally, I would want a table like this: 

 

YearPrize
1955David 
1956Abhi Bhattachararya
1957Motilal
1958Raj Mehra
1959Johnny Walker
......

 

I tried splitting the column by delimiter with a special character and the following options: 

  • #(lf)
  • #(cr)
  • <BR/>

But none works... This is what I get: 

 

Alienvolm_2-1622550674266.png

 

Thanks in advance for the help! 

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi @Anonymous ;

According to you description, You could split column and transpose table, then use List.Combine() .The steps are as follows:

Step1: Split Column

v-yalanwu-msft_0-1622687569104.jpeg

Step2: Transpose table

v-yalanwu-msft_1-1622687569108.jpeg

Step3: Write a function

v-yalanwu-msft_2-1622687569110.png

= Table.ToColumns(#"Removed Columns1")

v-yalanwu-msft_3-1622687569110.png

= List.Combine(Custom1)

v-yalanwu-msft_4-1622687569111.png

= Table.FromList(Custom2)

Step4: Split Column

v-yalanwu-msft_5-1622687569112.jpeg

Step5: Replace Values

v-yalanwu-msft_6-1622687569112.png

The final output is shown below:

v-yalanwu-msft_7-1622687569114.png

In addition, M language is as follows:

let

    Source = Web.BrowserContents("https://en.wikipedia.org/wiki/Amrish_Puri"),

    #"Extracted Table From Html" = Html.Table(Source, {{"Column1", "DIV.navbox:nth-child(1) > TABLE.nowraplinks.mw-collapsible.autocollapse.navbox-inner > * > TR > TH[colspan=""2""]:not([rowspan]):nth-child(1):nth-last-child(1), DIV.navbox:nth-child(1) > TABLE.nowraplinks.mw-collapsible.autocollapse.navbox-inner > * > TR > TH:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(2)"}, {"Column2", "DIV.navbox:nth-child(1) > TABLE.nowraplinks.mw-collapsible.autocollapse.navbox-inner > * > TR > TH[colspan=""2""]:not([rowspan]):nth-child(1):nth-last-child(1), DIV.navbox:nth-child(1) > TABLE.nowraplinks.mw-collapsible.autocollapse.navbox-inner > * > TR > TH:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(2) + TD:not([colspan]):not([rowspan]):nth-child(2):nth-last-child(1)"}}, [RowSelector="DIV.navbox:nth-child(1) > TABLE.nowraplinks.mw-collapsible.autocollapse.navbox-inner > * > TR"]),

    #"Changed Type" = Table.TransformColumnTypes(#"Extracted Table From Html",{{"Column1", type text}, {"Column2", type text}}),

    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Column1"}),

    #"Split Column by Delimiter" = Table.SplitColumn(#"Removed Columns", "Column2", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), {"Column2.1", "Column2.2", "Column2.3", "Column2.4", "Column2.5", "Column2.6", "Column2.7", "Column2.8", "Column2.9", "Column2.10", "Column2.11", "Column2.12", "Column2.13", "Column2.14", "Column2.15", "Column2.16", "Column2.17", "Column2.18", "Column2.19", "Column2.20", "Column2.21", "Column2.22", "Column2.23", "Column2.24", "Column2.25"}),

    #"Transposed Table" = Table.Transpose(#"Split Column by Delimiter"),

    #"Removed Columns1" = Table.RemoveColumns(#"Transposed Table",{"Column1"}),

    Custom1 = Table.ToColumns(#"Removed Columns1"),

    Custom2 = List.Combine(Custom1),

    Custom3 = Table.FromList(Custom2),

    #"Removed Blank Rows" = Table.SelectRows(Custom3, each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null}))),

    #"Split Column by Delimiter1" = Table.SplitColumn(#"Removed Blank Rows", "Column1", Splitter.SplitTextByDelimiter("(", QuoteStyle.Csv), {"Column1.1", "Column1.2"}),

    #"Replaced Value" = Table.ReplaceValue(#"Split Column by Delimiter1",")","",Replacer.ReplaceText,{"Column1.2"}),

    #"Reordered Columns" = Table.ReorderColumns(#"Replaced Value",{"Column1.2", "Column1.1"}),

    #"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Column1.2", "Year"}, {"Column1.1", "Prize"}})

in

    #"Renamed Columns"

Best Regards,
Community Support Team_ Yalan Wu
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

7 REPLIES 7
v-yalanwu-msft
Community Support
Community Support

Hi @Anonymous ;

According to you description, You could split column and transpose table, then use List.Combine() .The steps are as follows:

Step1: Split Column

v-yalanwu-msft_0-1622687569104.jpeg

Step2: Transpose table

v-yalanwu-msft_1-1622687569108.jpeg

Step3: Write a function

v-yalanwu-msft_2-1622687569110.png

= Table.ToColumns(#"Removed Columns1")

v-yalanwu-msft_3-1622687569110.png

= List.Combine(Custom1)

v-yalanwu-msft_4-1622687569111.png

= Table.FromList(Custom2)

Step4: Split Column

v-yalanwu-msft_5-1622687569112.jpeg

Step5: Replace Values

v-yalanwu-msft_6-1622687569112.png

The final output is shown below:

v-yalanwu-msft_7-1622687569114.png

In addition, M language is as follows:

let

    Source = Web.BrowserContents("https://en.wikipedia.org/wiki/Amrish_Puri"),

    #"Extracted Table From Html" = Html.Table(Source, {{"Column1", "DIV.navbox:nth-child(1) > TABLE.nowraplinks.mw-collapsible.autocollapse.navbox-inner > * > TR > TH[colspan=""2""]:not([rowspan]):nth-child(1):nth-last-child(1), DIV.navbox:nth-child(1) > TABLE.nowraplinks.mw-collapsible.autocollapse.navbox-inner > * > TR > TH:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(2)"}, {"Column2", "DIV.navbox:nth-child(1) > TABLE.nowraplinks.mw-collapsible.autocollapse.navbox-inner > * > TR > TH[colspan=""2""]:not([rowspan]):nth-child(1):nth-last-child(1), DIV.navbox:nth-child(1) > TABLE.nowraplinks.mw-collapsible.autocollapse.navbox-inner > * > TR > TH:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(2) + TD:not([colspan]):not([rowspan]):nth-child(2):nth-last-child(1)"}}, [RowSelector="DIV.navbox:nth-child(1) > TABLE.nowraplinks.mw-collapsible.autocollapse.navbox-inner > * > TR"]),

    #"Changed Type" = Table.TransformColumnTypes(#"Extracted Table From Html",{{"Column1", type text}, {"Column2", type text}}),

    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Column1"}),

    #"Split Column by Delimiter" = Table.SplitColumn(#"Removed Columns", "Column2", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), {"Column2.1", "Column2.2", "Column2.3", "Column2.4", "Column2.5", "Column2.6", "Column2.7", "Column2.8", "Column2.9", "Column2.10", "Column2.11", "Column2.12", "Column2.13", "Column2.14", "Column2.15", "Column2.16", "Column2.17", "Column2.18", "Column2.19", "Column2.20", "Column2.21", "Column2.22", "Column2.23", "Column2.24", "Column2.25"}),

    #"Transposed Table" = Table.Transpose(#"Split Column by Delimiter"),

    #"Removed Columns1" = Table.RemoveColumns(#"Transposed Table",{"Column1"}),

    Custom1 = Table.ToColumns(#"Removed Columns1"),

    Custom2 = List.Combine(Custom1),

    Custom3 = Table.FromList(Custom2),

    #"Removed Blank Rows" = Table.SelectRows(Custom3, each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null}))),

    #"Split Column by Delimiter1" = Table.SplitColumn(#"Removed Blank Rows", "Column1", Splitter.SplitTextByDelimiter("(", QuoteStyle.Csv), {"Column1.1", "Column1.2"}),

    #"Replaced Value" = Table.ReplaceValue(#"Split Column by Delimiter1",")","",Replacer.ReplaceText,{"Column1.2"}),

    #"Reordered Columns" = Table.ReorderColumns(#"Replaced Value",{"Column1.2", "Column1.1"}),

    #"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Column1.2", "Year"}, {"Column1.1", "Prize"}})

in

    #"Renamed Columns"

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you very much! 🙂

Greg_Deckler
Community Champion
Community Champion

@Anonymous What is the source? Also, can you share the source file?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler 

 

The source is a Wikipedia page: 

en.wikipedia.org/wiki/Amrish_Puri

 

For now, I split by delimiter with ) and it more or less worked: I still see the breakline before the name I haven't been able to remove it in any way. I have the table I wanted, but it would be nice to know what to use in these cases...

 

Thanks! 

@Anonymous You need to use the Split using special character option. Or you can just edit the M code in Advanced Editor:

Table.SplitColumn(#"Changed Type", "Column2", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv)

 

Greg_Deckler_0-1622555073260.png

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler 

 

None of these work for me... 

 

Alienvolm_0-1622555722447.png

 

This is the result: 

 

Alienvolm_1-1622555756175.png

 

😐 

@Anonymous Not sure what is different, mine worked first time. See the attached PBIX file below signature.

 

#"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column2", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), {"Column2.1", "Column2.2", "Column2.3", "Column2.4", "Column2.5", "Column2.6", "Column2.7", "Column2.8", "Column2.9", "Column2.10", "Column2.11", "Column2.12", "Column2.13", "Column2.14", "Column2.15", "Column2.16", "Column2.17", "Column2.18", "Column2.19", "Column2.20", "Column2.21", "Column2.22", "Column2.23", "Column2.24", "Column2.25"}),



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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