power query distribute stock to customers

i have a table with product code, Warehouse Location and Stock Quantity(Warehouse Stock)

product code Warehouse Location Stock quantity
1 a 2
1 b 5
1 c 3
2 a 5
2 b 5

a second table with the following information (Customers Orders)

customer product code order quantity
John 1 3
John 2 2
Mark 1 5
Mark 2 7
George 1 2
George 2 1

Is there a way in power query to create a third table that will distribute the pickup quantity to the warehouse Location? something like table no3?

customer product code picking Quantity Warehouse Location
John 1 2 a
John 1 1 b
John 2 2 a
Mark 1 4 b
Mark 1 1 c
Mark 2 3 a
Mark 2 4 b
George 1 2 c
George 2 1 c

Leave a Comment