let
// I used sample binary data. Import the Source with the actual table below
// Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("tZU9DoMwDIWvUmVmwCYpcIvuiLEbolKr3r9TK7fNj58TBhSEnM+P59hZFne53h+3/USuc+9nf25bYaHoq1zW7sPmaFQyE8QecsGkoiXZPukJ4FSCHTBp5YSCfW6lV+wX+LEdN4afFOcC+PJrzmw+6CrvqQf/HKwtRc50dQUknw32AtWlIR1mbgHJ9yX9dX1LoQaq0P/fvCV/oHlJI8zH/J9UirDkkj8fW1/uFaIq7hTO7m2gn3Nq0cJG+NkL1zQmvuYDe5N+PT8coX99AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Row Labels" = _t, #"Class 1" = _t, #"Class 2" = _t, #"Class 3" = _t, #"Class 4" = _t, #"Class 5" = _t, #"Class 6" = _t, #"Class 7" = _t, #"Class 8" = _t, #"Class 9" = _t, #"Class 10" = _t, #"Class 11" = _t, #"Class 12" = _t, #"Class 13" = _t]),
ChangeTypes = Table.TransformColumnTypes(Source,{{"Row Labels", type text}, {"Class 1", Int64.Type}, {"Class 2", Int64.Type}, {"Class 3", Int64.Type}, {"Class 4", Int64.Type}, {"Class 5", Int64.Type}, {"Class 6", Int64.Type}, {"Class 7", Int64.Type}, {"Class 8", Int64.Type}, {"Class 9", Int64.Type}, {"Class 10", Int64.Type}, {"Class 11", type text}, {"Class 12", type text}, {"Class 13", Int64.Type}}),
UnpivotColumns = Table.UnpivotOtherColumns(ChangeTypes, {"Row Labels"}, "Attribute", "Value"),
FilterRows = Table.SelectRows(UnpivotColumns, each ([Value] = 1)),
RemoveColumn = Table.RemoveColumns(FilterRows,{"Value"}),
GroupRows = Table.Group(RemoveColumn, {"Row Labels"}, {{"Classes", each _, type table [Row Labels=text, Attribute=text]}}),
IndexClasses = Table.TransformColumns(GroupRows,
{"Classes", (r) => Table.AddIndexColumn(r, "Index", 1)}
),
GroupClasses = Table.TransformColumns(IndexClasses,
{"Classes", (r) => Table.AddColumn(r, "Classes", each Table.RemoveRows(r, 0, [Index]))}
),
ExpandClasses = Table.ExpandTableColumn(GroupClasses, "Classes", {"Attribute", "Classes"}, {"Classes.Attribute", "Classes.Classes"}),
ExpandSubClasses = Table.ExpandTableColumn(ExpandClasses, "Classes.Classes", {"Attribute"}, {"Classes.Classes.Attribute"}),
RemoveNulls = Table.SelectRows(ExpandSubClasses, each ([Classes.Classes.Attribute] <> null)),
CombineClasses = Table.AddColumn(RemoveNulls, "Custom", each [Classes.Attribute] & " & " & [Classes.Classes.Attribute]),
Result = Table.RemoveColumns(CombineClasses,{"Classes.Attribute", "Classes.Classes.Attribute"})
in
Result