我试图找到一起产生物品率的表格。我在Excel中有一个表,它是行和列中唯一的ID列表。然后,我计算并划分他们匹配且不匹配的销售订单编号。我试图在power bi中复制它,但我还是有点新的把它拉下来。我曾尝试过几种方式的转向,但我不确定我是否走在正确的道路上。
基本上来自
产品|销售订单
A | 1
B | 1
A | 2
B | 3
C | 4
类似
| A | B | C |
A | 1.0 | 0.33 | 0.0
乙| 0.33 | 1.0 | 0.0
C ^ | 0.0 | 0.0 | 1.0 |
非常感谢任何帮助
答案 0 :(得分:0)
我的建议有3个查询:
表1(输入)。
OrdersPerProduct:包含唯一产品的表格及其唯一订单的嵌套列表。
结果:产生所需的输出。
查询OrdersPerProduct:
let
Source = Table1,
#"Grouped Rows" = Table.Group(Source, {"Product"}, {{"Orders", each List.Distinct(_[Order]), type list}})
in
#"Grouped Rows"
查询结果:
注意动态"更改类型"的最后一步所有产品列
let
Source = OrdersPerProduct,
#"Removed Columns" = Table.RemoveColumns(Source,{"Orders"}),
#"Added Custom" = Table.AddColumn(#"Removed Columns", "OtherProduct", each #"Removed Columns"[Product], type {text}),
#"Expanded OtherProduct" = Table.ExpandListColumn(#"Added Custom", "OtherProduct"),
#"Merged Queries" = Table.NestedJoin(#"Expanded OtherProduct",{"Product"},OrdersPerProduct,{"Product"},"ProductOrders",JoinKind.LeftOuter),
#"Expanded ProductOrders" = Table.ExpandTableColumn(#"Merged Queries", "ProductOrders", {"Orders"}, {"ProductOrders"}),
#"Merged Queries1" = Table.NestedJoin(#"Expanded ProductOrders",{"OtherProduct"},OrdersPerProduct,{"Product"},"NewColumn",JoinKind.LeftOuter),
#"Expanded NewColumn" = Table.ExpandTableColumn(#"Merged Queries1", "NewColumn", {"Orders"}, {"OtherProductOrders"}),
#"Added Custom1" = Table.AddColumn(#"Expanded NewColumn", "Rate", each List.Count(List.Intersect({[ProductOrders],[OtherProductOrders]})) / List.Count(List.Distinct(List.Combine({[ProductOrders],[OtherProductOrders]})))),
#"Removed Columns1" = Table.RemoveColumns(#"Added Custom1",{"ProductOrders", "OtherProductOrders"}),
#"Pivoted Column" = Table.Pivot(#"Removed Columns1", List.Distinct(#"Removed Columns1"[OtherProduct]), "OtherProduct", "Rate"),
#"Changed Type" = Table.TransformColumnTypes(#"Pivoted Column",List.Transform(#"Pivoted Column"[Product], each {_, type number}))
in
#"Changed Type"