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
Anonymous
Not applicable

How to separate Text with commas and different Text ordered

Hi Folks, 

 

I have the following issue, and I am not sure how should I fix it. What I am trying to do is basically separate text by commas from a single column I tried to use the  Add Column > Extract option, but since there is a lot of text and it does not follow a patron I am struggling on it. 

 

I have the following text as example: 

MichaelP8989_0-1615397116096.png

 

And sometimes the Column A the patron is not the same for example it could be only Effort,other and I need to have all the efforts on the same column, and all the Others in the same column. 

 

Basically, I am trying to classify these text. I would really appreciate your help, if anyone can suggest me any idea? 

 

Thank you so much. 

 

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

Hi, @Anonymous 

 

Based on your description, I assume that you want to align the split text to the right. I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

a1.png

 

You may apply the following transformations in the 'Advanced Editor'.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8s7LL89JTUlPTUzKSdVxzS1ILMlILclM1nFNS8tMzkzNK9FxzkksyiypBInkF5Xo+AMVFCnF6kQrkaiasBLsErEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Column A" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column A", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column A", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Column A.1", "Column A.2", "Column A.3", "Column A.4", "Column A.5", "Column A.6"}),
    #"Added Custom" = Table.AddColumn(#"Split Column by Delimiter", "Custom", each List.RemoveNulls( Record.ToList(_) )),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each List.Count([Custom])),
    Custom1 = Table.TransformColumns(#"Added Custom1",{"Custom",each let
l=List.Max(#"Added Custom1"[Custom.1]),
res=List.Combine({ List.Repeat({null},l-List.Count(_)),_})
in 
res

}),
    #"Removed Columns" = Table.RemoveColumns(Custom1,{"Column A.1", "Column A.2", "Column A.3", "Column A.4", "Column A.5", "Column A.6", "Custom.1"}),
    Custom2 = Table.TransformColumns(#"Removed Columns",{"Custom",each Record.FromList(_,Table.ColumnNames(#"Split Column by Delimiter") )}),
    #"Expanded Custom" = Table.ExpandRecordColumn(Custom2, "Custom", {"Column A.1", "Column A.2", "Column A.3", "Column A.4", "Column A.5", "Column A.6"}, {"Column A.1", "Column A.2", "Column A.3", "Column A.4", "Column A.5", "Column A.6"})
in
    #"Expanded Custom"

 

Result:

a2.png

 

Best Regards

Allan

 

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-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I assume that you want to align the split text to the right. I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

a1.png

 

You may apply the following transformations in the 'Advanced Editor'.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8s7LL89JTUlPTUzKSdVxzS1ILMlILclM1nFNS8tMzkzNK9FxzkksyiypBInkF5Xo+AMVFCnF6kQrkaiasBLsErEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Column A" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column A", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column A", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Column A.1", "Column A.2", "Column A.3", "Column A.4", "Column A.5", "Column A.6"}),
    #"Added Custom" = Table.AddColumn(#"Split Column by Delimiter", "Custom", each List.RemoveNulls( Record.ToList(_) )),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each List.Count([Custom])),
    Custom1 = Table.TransformColumns(#"Added Custom1",{"Custom",each let
l=List.Max(#"Added Custom1"[Custom.1]),
res=List.Combine({ List.Repeat({null},l-List.Count(_)),_})
in 
res

}),
    #"Removed Columns" = Table.RemoveColumns(Custom1,{"Column A.1", "Column A.2", "Column A.3", "Column A.4", "Column A.5", "Column A.6", "Custom.1"}),
    Custom2 = Table.TransformColumns(#"Removed Columns",{"Custom",each Record.FromList(_,Table.ColumnNames(#"Split Column by Delimiter") )}),
    #"Expanded Custom" = Table.ExpandRecordColumn(Custom2, "Custom", {"Column A.1", "Column A.2", "Column A.3", "Column A.4", "Column A.5", "Column A.6"}, {"Column A.1", "Column A.2", "Column A.3", "Column A.4", "Column A.5", "Column A.6"})
in
    #"Expanded Custom"

 

Result:

a2.png

 

Best Regards

Allan

 

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

ImkeF
Community Champion
Community Champion

Hello @Anonymous ,
I don't understand your request.

Please check out these tips to get you questions answered quickly: 

help how to get your questions answered quickly - Microsoft Power BI Community 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Top Solution Authors