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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
thisisausername
Helper II
Helper II

Split by Column but with variable number of delimiters?

When I do Split by Column I can choose my delimiter, but when I expand 'Advanced options' I can see it's going to use the maximum number of delimiters I have at this time.

 

How can I do the same function (split column by delimiter into new columns) but with a dynamic max number of delimiters, as this will sometimes change? 

 

SplitColumn.png

 

Thank you

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

Hi @thisisausername,

 

Refering to the video, I made a sample for your reference. Here we can split the column without setting the number of delimiters. M code for your reference.

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCklNzDXUTUzUTUrSTU5WitWBCBkBhRLhPGOgVLJuSkoKXMRE19DIWNfYyMhIKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column", type text}}),
    #"Lowercased Text" = Table.TransformColumns(#"Changed Type",{{"Column", Splitter.SplitTextByDelimiter("-"), type text}}),
    Column = #"Lowercased Text"[Column],
    #"Converted to Table" = Table.FromList(Column, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandListColumn(#"Converted to Table", "Column1"),
    #"Added Conditional Column" = Table.AddColumn(#"Expanded Column1", "Custom", each if Text.StartsWith([Column1], "Team") then [Column1] else null),
    #"Filled Down" = Table.FillDown(#"Added Conditional Column",{"Custom"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each not Text.StartsWith([Column1], "Team")),
    #"Reordered Columns" = Table.ReorderColumns(#"Filtered Rows",{"Custom", "Column1"})
in
    #"Reordered Columns"

2.PNGCapture.PNG

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

4 REPLIES 4
v-frfei-msft
Community Support
Community Support

Hi @thisisausername,

 

Refering to the video, I made a sample for your reference. Here we can split the column without setting the number of delimiters. M code for your reference.

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCklNzDXUTUzUTUrSTU5WitWBCBkBhRLhPGOgVLJuSkoKXMRE19DIWNfYyMhIKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column", type text}}),
    #"Lowercased Text" = Table.TransformColumns(#"Changed Type",{{"Column", Splitter.SplitTextByDelimiter("-"), type text}}),
    Column = #"Lowercased Text"[Column],
    #"Converted to Table" = Table.FromList(Column, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandListColumn(#"Converted to Table", "Column1"),
    #"Added Conditional Column" = Table.AddColumn(#"Expanded Column1", "Custom", each if Text.StartsWith([Column1], "Team") then [Column1] else null),
    #"Filled Down" = Table.FillDown(#"Added Conditional Column",{"Custom"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each not Text.StartsWith([Column1], "Team")),
    #"Reordered Columns" = Table.ReorderColumns(#"Filtered Rows",{"Custom", "Column1"})
in
    #"Reordered Columns"

2.PNGCapture.PNG

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Great video!

Anonymous
Not applicable

Oh your video just made my day!

Nathaniel_C
Super User
Super User

Hi @thisisausername ,

"Each occurance" option should cover that. If you don't add anything into how many columns Power Query does that for you.

 


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors