Forum Discussion

Djpejsen's avatar
Djpejsen
Frequent Visitor
4 years ago
Solved

Power Query - Inventory allocation

Hi Experts I have a table of Sales orders with shipments priority and requested qty. (Table A) Every week I receive a delivery plan from our vendors. (Table B) I have to provide a Shipment deliver...
  • v-kelly-msft's avatar
    v-kelly-msft
    4 years ago

    Hi Djpejsen ,

     

    Sorry for the late reply.

    It is indeed not an easy case and it did take me many days.

    I cant find a simpler way.Hope my way below would be a solution for you.

    First go to query editor>unpivot columns to get below table:

    Then in outbound table,I create several columns to tranform the data.

    Finally,I got below calculated table.

    Table =
    DISTINCT (
        UNION (
            SELECTCOLUMNS (
                'outbound',
                "Sales Order", [Sales order],
                "Item", 'outbound'[Item],
                "Proritet", 'outbound'[_proritet],
                "Qty", 'outbound'[final adjust],
                "Index", 'outbound'[Index]
            ),
            SELECTCOLUMNS (
                'outbound',
                "Sales Order", [Sales order],
                "Item", 'outbound'[Item],
                "Proritet", 'outbound'[new proritet],
                "Qty", 'outbound'[round1],
                "Index", 'outbound'[new index]
            )
        )
    )
    

    And you will see:

    What you want is as below:

    For the related .pbix file,pls see attached.

     

    Best Regards,
    Kelly

    Did I answer your question? Mark my reply as a solution!