我有这个 csv:
car color code city
ferrari pink 01 LA
ferrari red 02 LA
lambo yellow 09 Texas
lambo orange 08 Texas
我想在powerbi中进行这种分组,按汽车和城市分组,列出代码和颜色的唯一值并计算唯一行数。 预期产出:
car color code city count
ferrari [pink, red] [01,02] LA 2
lambo [yellow, orange] [09,08] Texas 2
也许 CONCATENEX ?但真的不知道
给你。
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSkstKkosylTSUSrIzMsGUoZA7OOoFKuDLFeUmgIkjRBSOYm5SflAbmVqTk5+OZBhCcQhqRWJxSjS+UWJeempQIYFQjoWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [car = _t, color = _t, code = _t, city = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"car", type text}, {"color", type text}, {"code", type text}, {"city", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"car", "city"}, {{"count", each Table.RowCount(_), Int64.Type}, {"color", each "["& Text.Combine( _[color],",")&"]", type text },{"code", each "["& Text.Combine( _[code],",")&"]", type text }}),
#"Reordered Columns" = Table.ReorderColumns(#"Grouped Rows",{"car", "color", "code", "city", "count"})
in
#"Reordered Columns"