Forum Discussion
DAX generated table with related data
- Anonymous5 years ago
Hi Anonymous
You need to duplicate a same table like original one, and change all the column names in new table. Because Power BI doesn't support two columns have the same name. Then you can build a dax code as below to build the table you want.
New Table = VAR _T = CROSSJOIN ( 'Table', 'Ass Table' ) VAR _T2 = SUMMARIZE ( FILTER ( _T, [Product ID] <> [Ass Product ID] && [Transaction ID] = [Ass Transaction ID] ), [Product ID], [Ass Product ID], "QTY", SUM ( 'Table'[Qty] ), "Count of Transactions", COUNT ( 'Table'[Transaction ID] ) ) RETURN _T2Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I think your sample result has a typo.
Here's the general approach.
- take your original table
- duplicate it and rename all columns
- create a new table as a cross join of the two tables
- eliminate all rows where the products are the same, and all rows where the transaction IDs are not the same.
- load into the table visual
Thanks for your help. I went with the SUMMARIZE() approach as I than could have the count of transactions in the table, but thank you for breaking the logic down for me, much appreciated.