illusionek
Board Regular
- Joined
- Jun 21, 2014
- Messages
- 104
Hi Guys
Please could you help me to develop this solution in the Power Query. I believe I understand steps I need to go through or at least this is how I would do it in MS Access but not sure how to do it in PQ as I am really new to this. I especially struggle with Steps 4, 5, 6
1 Bring all tables into the data model
2 Group by Product/Item No & Colour to get total quantity for each as there may be duplicates in each column
3 Append both tables for Product/Item No and Colour
4 ‘Select Distinct’ from appended table to get unique list of Product/Item Nos and Colours
5 Create new table with the list from Step 4
6 Create a link between table from Step 5 and tables from Step 2. Link is based on the combination of Product/Item No & Colour (ie concatenate)
7 Bring qtys from both columns
8 Create function to deduct one from the other
Table A
[TABLE="width: 185"]
<tbody>[TR]
[TD]Item No[/TD]
[TD]Colour[/TD]
[TD]Qty[/TD]
[TD]Supplier[/TD]
[/TR]
[TR]
[TD]A123[/TD]
[TD]Blue[/TD]
[TD="align: right"]1[/TD]
[TD]S123[/TD]
[/TR]
[TR]
[TD]B123[/TD]
[TD]Pink[/TD]
[TD="align: right"]3[/TD]
[TD]S456[/TD]
[/TR]
[TR]
[TD]A123[/TD]
[TD]Blue[/TD]
[TD="align: right"]4[/TD]
[TD]S123[/TD]
[/TR]
[TR]
[TD]C123[/TD]
[TD]White[/TD]
[TD="align: right"]3[/TD]
[TD]S456[/TD]
[/TR]
[TR]
[TD]D123[/TD]
[TD]Green[/TD]
[TD="align: right"]2[/TD]
[TD]S456[/TD]
[/TR]
[TR]
[TD]D123[/TD]
[TD]Pink[/TD]
[TD="align: right"]1[/TD]
[TD]S123[/TD]
[/TR]
</tbody>[/TABLE]
Table B
[TABLE="width: 284"]
<tbody>[TR]
[TD]Product No[/TD]
[TD]Colour Name[/TD]
[TD]Quantity[/TD]
[TD]Customer[/TD]
[/TR]
[TR]
[TD]A123[/TD]
[TD]Blue[/TD]
[TD="align: right"]3[/TD]
[TD]ABC[/TD]
[/TR]
[TR]
[TD]B123[/TD]
[TD]Black[/TD]
[TD="align: right"]4[/TD]
[TD]CDE[/TD]
[/TR]
[TR]
[TD]A123[/TD]
[TD]Blue[/TD]
[TD="align: right"]5[/TD]
[TD]FEG[/TD]
[/TR]
[TR]
[TD]C123[/TD]
[TD]White[/TD]
[TD="align: right"]2[/TD]
[TD]ABC[/TD]
[/TR]
[TR]
[TD]D123[/TD]
[TD]Green[/TD]
[TD="align: right"]3[/TD]
[TD]FEG[/TD]
[/TR]
[TR]
[TD]D123[/TD]
[TD]Grey[/TD]
[TD="align: right"]1[/TD]
[TD]CDE[/TD]
[/TR]
</tbody>[/TABLE]
Results
[TABLE="width: 321"]
<tbody>[TR]
[TD]Product No[/TD]
[TD]Colour Name[/TD]
[TD]Table A[/TD]
[TD]Table B[/TD]
[TD]Variance[/TD]
[/TR]
[TR]
[TD]A123[/TD]
[TD]Blue[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]-3[/TD]
[/TR]
[TR]
[TD]B123[/TD]
[TD]Black[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]-4[/TD]
[/TR]
[TR]
[TD]B123[/TD]
[TD]Pink[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD]C123[/TD]
[TD]White[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]D123[/TD]
[TD]Green[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]-1[/TD]
[/TR]
[TR]
[TD]D123[/TD]
[TD]Grey[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]-1[/TD]
[/TR]
[TR]
[TD]D123[/TD]
[TD]Pink[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]1[/TD]
[/TR]
</tbody>[/TABLE]
Please could you help me to develop this solution in the Power Query. I believe I understand steps I need to go through or at least this is how I would do it in MS Access but not sure how to do it in PQ as I am really new to this. I especially struggle with Steps 4, 5, 6
1 Bring all tables into the data model
2 Group by Product/Item No & Colour to get total quantity for each as there may be duplicates in each column
3 Append both tables for Product/Item No and Colour
4 ‘Select Distinct’ from appended table to get unique list of Product/Item Nos and Colours
5 Create new table with the list from Step 4
6 Create a link between table from Step 5 and tables from Step 2. Link is based on the combination of Product/Item No & Colour (ie concatenate)
7 Bring qtys from both columns
8 Create function to deduct one from the other
Table A
[TABLE="width: 185"]
<tbody>[TR]
[TD]Item No[/TD]
[TD]Colour[/TD]
[TD]Qty[/TD]
[TD]Supplier[/TD]
[/TR]
[TR]
[TD]A123[/TD]
[TD]Blue[/TD]
[TD="align: right"]1[/TD]
[TD]S123[/TD]
[/TR]
[TR]
[TD]B123[/TD]
[TD]Pink[/TD]
[TD="align: right"]3[/TD]
[TD]S456[/TD]
[/TR]
[TR]
[TD]A123[/TD]
[TD]Blue[/TD]
[TD="align: right"]4[/TD]
[TD]S123[/TD]
[/TR]
[TR]
[TD]C123[/TD]
[TD]White[/TD]
[TD="align: right"]3[/TD]
[TD]S456[/TD]
[/TR]
[TR]
[TD]D123[/TD]
[TD]Green[/TD]
[TD="align: right"]2[/TD]
[TD]S456[/TD]
[/TR]
[TR]
[TD]D123[/TD]
[TD]Pink[/TD]
[TD="align: right"]1[/TD]
[TD]S123[/TD]
[/TR]
</tbody>[/TABLE]
Table B
[TABLE="width: 284"]
<tbody>[TR]
[TD]Product No[/TD]
[TD]Colour Name[/TD]
[TD]Quantity[/TD]
[TD]Customer[/TD]
[/TR]
[TR]
[TD]A123[/TD]
[TD]Blue[/TD]
[TD="align: right"]3[/TD]
[TD]ABC[/TD]
[/TR]
[TR]
[TD]B123[/TD]
[TD]Black[/TD]
[TD="align: right"]4[/TD]
[TD]CDE[/TD]
[/TR]
[TR]
[TD]A123[/TD]
[TD]Blue[/TD]
[TD="align: right"]5[/TD]
[TD]FEG[/TD]
[/TR]
[TR]
[TD]C123[/TD]
[TD]White[/TD]
[TD="align: right"]2[/TD]
[TD]ABC[/TD]
[/TR]
[TR]
[TD]D123[/TD]
[TD]Green[/TD]
[TD="align: right"]3[/TD]
[TD]FEG[/TD]
[/TR]
[TR]
[TD]D123[/TD]
[TD]Grey[/TD]
[TD="align: right"]1[/TD]
[TD]CDE[/TD]
[/TR]
</tbody>[/TABLE]
Results
[TABLE="width: 321"]
<tbody>[TR]
[TD]Product No[/TD]
[TD]Colour Name[/TD]
[TD]Table A[/TD]
[TD]Table B[/TD]
[TD]Variance[/TD]
[/TR]
[TR]
[TD]A123[/TD]
[TD]Blue[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]-3[/TD]
[/TR]
[TR]
[TD]B123[/TD]
[TD]Black[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]-4[/TD]
[/TR]
[TR]
[TD]B123[/TD]
[TD]Pink[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD]C123[/TD]
[TD]White[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]D123[/TD]
[TD]Green[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]-1[/TD]
[/TR]
[TR]
[TD]D123[/TD]
[TD]Grey[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]-1[/TD]
[/TR]
[TR]
[TD]D123[/TD]
[TD]Pink[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]1[/TD]
[/TR]
</tbody>[/TABLE]