Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Only Return Work Order Numbers After Amount Is Distributed

Good Day,

 

I am only wanting to return workorders where we didn't have enough quantityonhand to cover the order.

In the example below quantityonhand in IM_ItemWarehouse is 139.  I need quantityonhand to be distributed to the QtyCommitted amount in WO2_WorkOrderMaterialDetail in order of earliest to latest WODueDates, this would cover WorkOrder 0082975 leaving 29 left. Then the next earliest date is WorkOrder 0082966 with 108 – leaving me 79 short so I would need to return this (0082966) workorder. The next few WorkOrders have 0 committed so they are not in the report, then it shows WorkOrders 0083655 & 0083646 being short 50 & 42 because there is no qty left to cover it. So what I would need returned are WorkOrders 0082966, 0083655 & 0083646 with their quantity short amounts. Does anyone know how I can accomplish this?


IM_ItemWarehouse 

 

WO2_WorkOrderMaterialDetail



Expected outcome

 

Anonymous 

 

Thanks so much,

Lydia

9 Replies

  • You could create a measure like

    Shortfall =
    SUMX (
        WO2_WorkOrderMaterialDetail,
        VAR QuantityOnHand =
            RELATED ( IM_ItemWarehouse[QuantityOnHand] )
        VAR RequiredAmount = WO2_WorkOrderMaterialDetail[QtyCommitted]
        VAR CurrentDate = WO2_WorkOrderMaterialDetail[WO_Due_Date]
        VAR PreviouslyUsed =
            CALCULATE (
                SUM ( WO2_WorkOrderMaterialDetail[QtyCommitted] ),
                ALLEXCEPT (
                    WO2_WorkOrderMaterialDetail,
                    WO2_WorkOrderMaterialDetail[ComponentID]
                ),
                WO2_WorkOrderMaterialDetail[WO_Due_Date] < CurrentDate
            )
        VAR AvailableStock =
            MAX ( QuantityOnHand - PreviouslyUsed, 0 )
        RETURN
            RequiredAmount - AvailableStock
    )
    

    and then use this in a table visual with the work order number, and filter it to only show when the value is > 0

    • Anonymous's avatar
      Anonymous
      Not applicable

      Jolly Morning John,

      This looks to almost be what I need! 🤘

      Could you help me finishing it? Here is an example of what I am expecting the table to look like

       


      I have a 26 of these on hand currently and here are all my orders that would need that amount distributed out.

       


      Youll see once you get to WO HY910-1 I already have 25 of the total 26 distributed out. Meaning that there is only 1 left to fill the 2 required (QTYCommited column). So I would expect to see the shortfall amount = 1. Instead I am getting -16. Here is what I am getting in my table visual after dragging all my fields in.

      Any other suggestions?

       

      Thanks!!

      • johnt75's avatar
        johnt75
        Super User

        Not sure how its returning negative numbers at all. Can you share some sample data via dropbox or Google Drive or similar ?