Forum Discussion
vpatel55
Kudo Commander
5 years agoCreating a new table with a cartesian product column
Hello, I am trying to create a new table containing every combination of Product in within one transaction id. So if transaction 1 contained 3 different products, that would be 3 x 3 = 9 combinat...
- 5 years ago
Try this calculated table. The SELECTCOLUMNS function is necessary in order to rename the Product column, since CROSSJOIN doesn't allow two columns with the same name.
Cross Join = GENERATE ( SUMMARIZE ( Data, Data[Transaction Id], Data[Customer] ), VAR vTransId = Data[Transaction Id] VAR vProduct1 = CALCULATETABLE ( VALUES ( Data[Product] ), Data[Transaction Id] = vTransId ) VAR vProduct2 = SELECTCOLUMNS ( CALCULATETABLE ( VALUES ( Data[Product] ), Data[Transaction Id] = vTransId ), "Product2", Data[Product] ) RETURN CROSSJOIN ( vProduct1, vProduct2 ) )
vpatel55
Kudo Commander
5 years agoDataInsights , that works perfectly! I didn't think to use GENERATE. This had me stumped, so huge kudos for helping with this.