你可以试试这个
let
Source = Table.FromRows(
Json.Document(
Binary.Decompress(
Binary.FromText(
"ZZC7DoQgEEV/xVBbyMi+ar/AbY2FcSlIFIxisX+/qwzmisWEucPJnUfTiLdeJmc/eha5qNduMP6b1RIFoSj/onLj1FnGDkFBjKs1feeNs1mwXvTlo3LzrHsv2rwR1WC09dlmVXDc4N3qhCDthfC5RcmQ2nMAS3CIueL8BCpup9g56pADGOeS7EbsFmYF8A5AAUFp6wcX4wLy2DgBn8lc8Twqbf0CgMDxMqMsoJdK7E+9JVJ4xbBW2/4A",
BinaryEncoding.Base64
),
Compression.Deflate
)
),
let
_t = ((type nullable text) meta [Serialized.Text = true])
in
type table [
Column1 = _t,
#"Quality performance" = _t,
Column3 = _t,
Column4 = _t,
#"Company perception" = _t,
Column6 = _t,
Communication = _t,
Column8 = _t
]
),
ct = Table.TransformColumnTypes(
Source,
{
{"Column1", type text},
{"Quality performance", type text},
{"Column3", type text},
{"Column4", type text},
{"Company perception", type text},
{"Column6", type text},
{"Communication", type text},
{"Column8", type text}
}
),
DH = Table.DemoteHeaders(ct),
CT = Table.TransformColumnTypes(
DH,
{
{"Column1", type text},
{"Column2", type text},
{"Column3", type text},
{"Column4", type text},
{"Column5", type text},
{"Column6", type text},
{"Column7", type text},
{"Column8", type text}
}
),
KFR = Table.FirstN(CT, 1),
TT = Table.Transpose(KFR),
AC = Table.AddColumn(
TT,
"Custom",
each
if [Column1] = "Column1" then
ct[Column1]{0}
else if Text.Contains([Column1], "Column") then
null
else
[Column1]
),
RTR = Table.Skip(AC, 1),
FD = Table.FillDown(RTR, {"Custom"}),
#"Promoted Headers" = Table.PromoteHeaders(ct, [PromoteAllScalars = true]),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(
#"Promoted Headers",
{"Responder"},
"Attribute",
"Value"
),
#"Grouped Rows" = Table.Group(
#"Unpivoted Other Columns",
{"Responder"},
{{"ad", each _, type table [Responder = nullable text, Attribute = text, Value = text]}}
),
#"Added Custom" = Table.AddColumn(
#"Grouped Rows",
"Custom",
each
let
src = [ad],
Index = Table.AddIndexColumn(src, "Index", 0, 1),
Add = Table.AddColumn(Index, "Custom", each FD[Custom]{[Index]}),
Remove = Table.RemoveColumns(Add, {"Index"}),
#"Added Custom1" = Table.AddColumn(
Remove,
"Custom.1",
each List.Difference(Text.Split([Attribute], " "), Text.Split([Custom], " "))
),
#"Expanded Custom.1" = Table.ExpandListColumn(#"Added Custom1", "Custom.1"),
#"Renamed Columns" = Table.RenameColumns(
#"Expanded Custom.1",
{{"Custom", "CAT"}, {"Custom.1", "SubCat"}}
),
#"Removed Columns" = Table.RemoveColumns(#"Renamed Columns", {"Attribute"}),
#"Changed Type" = Table.TransformColumnTypes(#"Removed Columns", {{"Value", type number}})
in
#"Changed Type"
),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom", {"Custom"}),
#"Expanded Custom" = Table.ExpandTableColumn(
#"Removed Other Columns",
"Custom",
{"Responder", "Value", "CAT", "SubCat"},
{"Responder", "Value", "CAT", "SubCat"}
)
in
#"Expanded Custom"