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! Learn more

Reply
bcosta98
Helper I
Helper I

Spliting Multiple Collumn into rows related to original Collumn

Hello, I'm having a trouble spliting tow collumns into rows and still making a relation between which collumn was the original data

 

This is what I have:

MessageIDSuccessUsersErrorUsers
1101,102103
2101,102,103 
3102101,103

 

And this is what I want:

MessageIDUserStatus
1101

1

11021
11030
21011
21021
21031
31021
31010
31030

In which Status = 1 represents Success and Status = 0 represents Error

1 ACCEPTED SOLUTION
nandukrishnavs
Community Champion
Community Champion

@bcosta98 

 

Try this in Edit Query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI0MNQxNDACs4yVYnWilYwQojogMR0lsLAxWBghCVQcCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [MessageID = _t, SuccessUsers = _t, ErrorUsers = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"SuccessUsers", type text}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"MessageID"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Unpivoted Columns", {{"Value", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Value"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"MessageID", Int64.Type}, {"Value", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type1", each ([Value] <> null)),
    #"Renamed Columns" = Table.RenameColumns(#"Filtered Rows",{{"Value", "User"}, {"Attribute", "Status"}}),
    #"Replaced Value" = Table.ReplaceValue(#"Renamed Columns","SuccessUsers","1",Replacer.ReplaceText,{"Status"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","ErrorUsers","0",Replacer.ReplaceText,{"Status"})
in
    #"Replaced Value1"

 

a.JPG 

Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂


Regards,
Nandu Krishna

View solution in original post

3 REPLIES 3
jthomson
Solution Sage
Solution Sage

- Split the success column by delimiter at each instance of a comma

- Split the error column by delimiter at each instance of a comma

- Select the MessageID column and unpivot other columns

- Create some sort of conditional column that gets you a 1 or 0, I used if Text.StartsWith([Attribute],"S") then 1 else 0

nandukrishnavs
Community Champion
Community Champion

@bcosta98 

 

Try this in Edit Query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI0MNQxNDACs4yVYnWilYwQojogMR0lsLAxWBghCVQcCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [MessageID = _t, SuccessUsers = _t, ErrorUsers = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"SuccessUsers", type text}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"MessageID"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Unpivoted Columns", {{"Value", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Value"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"MessageID", Int64.Type}, {"Value", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type1", each ([Value] <> null)),
    #"Renamed Columns" = Table.RenameColumns(#"Filtered Rows",{{"Value", "User"}, {"Attribute", "Status"}}),
    #"Replaced Value" = Table.ReplaceValue(#"Renamed Columns","SuccessUsers","1",Replacer.ReplaceText,{"Status"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","ErrorUsers","0",Replacer.ReplaceText,{"Status"})
in
    #"Replaced Value1"

 

a.JPG 

Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂


Regards,
Nandu Krishna

Thank you very much. Could you help me if I have more than 2 collumns?

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors