Forum Discussion
Create Table with all the possible group combinations
Yes, there is a function in Power Query that can create a table with all possible combinations. The function is called "Cartesian Join" or "Cross Join".
To create a table with all possible combinations of the Customer ID and DOC ID from your Table1, you can follow these steps:
Select your Table1 and click on the "Transform data" button.
In the Power Query Editor, click on the "Add Column" tab and select "Custom Column".
In the "Custom Column" dialog box, enter a name for the new column (e.g. "JoinKey") and enter the following formula: [Customer ID] & "-" & [DOC ID]
Click "OK" to create the new column.
Duplicate the Table1 by right-clicking on the Table1 in the Queries pane and selecting "Duplicate".
Rename the duplicated table as "Table2".
Remove the "Value" column from Table2.
Select both Table1 and Table2 in the Queries pane.
Click on the "Combine" button in the Home tab and select "Merge Queries".
In the "Merge" dialog box, select "JoinKey" as the join column for both tables.
Select "Cross Join" as the join kind.
Click "OK" to create the new table with all possible combinations.
To create the third table with the Unique ID combinations and the containing IDs, you can follow these steps:
Select your Table2 and click on the "Transform data" button.
In the Power Query Editor, click on the "Group By" button in the Home tab.
In the "Group By" dialog box, select "JoinKey" as the grouping column and select "All Rows" as the aggregation method.
Rename the new column as "DOC IDs".
Click "OK" to create the new table with unique JoinKeys and the containing DOC IDs.
Hello,
Thanks for the response, but unfortunatelly I'm not having the expected result.
After the merge I got this table, which is not ok.
Cheers,
Kta