Excel Power Query _count 每种尺寸有多少产品

Excel Power Query _count how many products have per size

在 excel 电源查询中我有产品、尺寸和库存。我想统计有多少产品只有 1 种尺寸、只有 2 种尺寸、只有 3 种尺寸等等

提前致谢

想要的结果

数据样本

将数据加载到 PowerQuery 后尝试此操作(数据 ... 来自 table/range)

单击 select 尺寸和子类别列,右键单击,分组依据

新名称:计数,操作:计数行。好的

单击 select 子类别和计数列,右键单击,分组依据

新名称:Count1,操作:计数行。好的

单击select 计数列

变换...透视列

值列:Count1

示例完整代码

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Grouped Rows" = Table.Group(Source, {"size", "sucategoty"}, {{"Count", each Table.RowCount(_), type number}}),
#"Grouped Rows1" = Table.Group(#"Grouped Rows", {"sucategoty", "Count"}, {{"Count.1", each Table.RowCount(_), type number}}),
#"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Grouped Rows1", {{"Count", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Grouped Rows1", {{"Count", type text}}, "en-US")[Count]), "Count", "Count.1", List.Sum)
in  #"Pivoted Column"