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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Split column by comma then pivot

Hi all,

 

I have a dataset that has multiple values in one column, in order, seprated by a comma. The data looks like this:

 

IDMarket AreaContract #close dateSolutionOPPOPP2
1East Coast 1112020-11-04,2020-11-20,2021-05-05Online,B2B, MailWeb,Social,MediaSocial

 

 

I am trying to accomplish this:

IDMarket AreaContract #close dateSolutionOPPOPP2
1East Coast 11111/4/2020OnlineWebSocial
1East Coast 11111/20/2020B2BSocial 
1East Coast 1115/5/2021MailMedia 

 

 

I tired to split by comma then unpoivot the columns but it seems to repete the wrong values in the unvoited column. Any ideas on how to do this correctly?

 

Thank you!

1 ACCEPTED SOLUTION
sevenhills
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJNLC5RcM4HkUCeoSFIzMjAyEDX0FDXwEQHxjQyADGBQqZABFTin5eTmZeq42TkpKPgm5iZAxQKT03SCc5PzkzM0fFNTclMBApBuEqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Market Area" = _t, #"Contract #" = _t, #"close date" = _t, Solution = _t, OPP = _t, OPP2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Market Area", type text}, {"Contract #", Int64.Type}, {"close date", type text}, {"Solution", type text}, {"OPP", type text}, {"OPP2", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Split([close date], ",")),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each Text.Split([Solution], ",")),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Custom.2", each Text.Split([OPP], ",")),
    #"Added Custom3" = Table.AddColumn(#"Added Custom2", "Custom.3", each Text.Split([OPP2], ",")),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom3",{"close date", "Solution", "OPP", "OPP2"}),
    #"Added Custom4" = Table.AddColumn(#"Removed Columns", "Custom.4", each Table.FromColumns({[Custom], [Custom.1], [Custom.2], [Custom.3]})),
    #"Removed Columns1" = Table.RemoveColumns(#"Added Custom4",{"Custom", "Custom.1", "Custom.2", "Custom.3"}),
    #"Expanded Custom.4" = Table.ExpandTableColumn(#"Removed Columns1", "Custom.4", {"Column1", "Column2", "Column3", "Column4"}, {"Column1", "Column2", "Column3", "Column4"})
in
    #"Expanded Custom.4"

 

Source:

sevenhills_0-1642561996452.png

 

 

Final output:

sevenhills_1-1642562028937.png

 

I Learned from this video and want to give credit: https://www.youtube.com/watch?v=JMOnr3DOqyk 

 

 

View solution in original post

3 REPLIES 3
sevenhills
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJNLC5RcM4HkUCeoSFIzMjAyEDX0FDXwEQHxjQyADGBQqZABFTin5eTmZeq42TkpKPgm5iZAxQKT03SCc5PzkzM0fFNTclMBApBuEqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Market Area" = _t, #"Contract #" = _t, #"close date" = _t, Solution = _t, OPP = _t, OPP2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Market Area", type text}, {"Contract #", Int64.Type}, {"close date", type text}, {"Solution", type text}, {"OPP", type text}, {"OPP2", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Split([close date], ",")),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each Text.Split([Solution], ",")),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Custom.2", each Text.Split([OPP], ",")),
    #"Added Custom3" = Table.AddColumn(#"Added Custom2", "Custom.3", each Text.Split([OPP2], ",")),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom3",{"close date", "Solution", "OPP", "OPP2"}),
    #"Added Custom4" = Table.AddColumn(#"Removed Columns", "Custom.4", each Table.FromColumns({[Custom], [Custom.1], [Custom.2], [Custom.3]})),
    #"Removed Columns1" = Table.RemoveColumns(#"Added Custom4",{"Custom", "Custom.1", "Custom.2", "Custom.3"}),
    #"Expanded Custom.4" = Table.ExpandTableColumn(#"Removed Columns1", "Custom.4", {"Column1", "Column2", "Column3", "Column4"}, {"Column1", "Column2", "Column3", "Column4"})
in
    #"Expanded Custom.4"

 

Source:

sevenhills_0-1642561996452.png

 

 

Final output:

sevenhills_1-1642562028937.png

 

I Learned from this video and want to give credit: https://www.youtube.com/watch?v=JMOnr3DOqyk 

 

 

Anonymous
Not applicable

thank you

You welcome

 

FYI, I had this requirement a while back and remembered the video and used for your needs. I want to give credit the video person, hence included the link

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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
Top Kudoed Authors