Forum Discussion
Estimated Delivery date based on cumulative count
- 4 years ago
learner03 OK, I simplified the equation and was able to eliminate the GENERATESERIES. Not sure why I didn't do it this way the first time. Try this one:
FIFO 2 = VAR __DaysToFulfill = 10 VAR __ItemCode = [Item Code] VAR __Date = [Date] VAR __QtyToFulfill = SUMX(FILTER('BackOrders',[Item Code] = __ItemCode && [Date] <= __Date),[Backorder Qty]) VAR __Table = FILTER('OpenPurchaseOrders',[Item Code] = __ItemCode) VAR __Table1 = ADDCOLUMNS( ADDCOLUMNS(__Table,"__tqty",SUMX(FILTER(__Table,[ETA W/H] <= EARLIER([ETA W/H])),[Quantity])), "__LoopCounter",[__tqty] - __QtyToFulfill ) VAR __TargetDate = MINX(FILTER(__Table1, [__LoopCounter] >= 0),[ETA W/H]) VAR __FulfillmentDate = IF(__TargetDate = BLANK(),BLANK(),__TargetDate+__DaysToFulfill) RETURN __FulfillmentDate
learner03 OK, I simplified the equation and was able to eliminate the GENERATESERIES. Not sure why I didn't do it this way the first time. Try this one:
FIFO 2 =
VAR __DaysToFulfill = 10
VAR __ItemCode = [Item Code]
VAR __Date = [Date]
VAR __QtyToFulfill = SUMX(FILTER('BackOrders',[Item Code] = __ItemCode && [Date] <= __Date),[Backorder Qty])
VAR __Table = FILTER('OpenPurchaseOrders',[Item Code] = __ItemCode)
VAR __Table1 =
ADDCOLUMNS(
ADDCOLUMNS(__Table,"__tqty",SUMX(FILTER(__Table,[ETA W/H] <= EARLIER([ETA W/H])),[Quantity])),
"__LoopCounter",[__tqty] - __QtyToFulfill
)
VAR __TargetDate = MINX(FILTER(__Table1, [__LoopCounter] >= 0),[ETA W/H])
VAR __FulfillmentDate = IF(__TargetDate = BLANK(),BLANK(),__TargetDate+__DaysToFulfill)
RETURN
__FulfillmentDate
Greg_Deckler Thanks Greg. I tried this one and checked couple of items, it works great with them as with desired result. I will check the same with the new updated file as this data was a week old. I will let you know if any issue occurs. I am acception this as a solution.Thanks again.
- Greg_Deckler4 years ago
Community Champion
learner03 Great to hear. If you need them, I revised the FIFO, LIFO and optimized columns and measures into FIFO 2, LIFO 2, etc. so you have 4 different ways of fulfilling backlog as both columns and measures without having to use GENERATESERIES. Attached PBIX.
- learner034 years ago
Post Partisan
Greg_Deckler That's Brilliant !! Thanks again
- learner034 years ago
Post Partisan
Greg_Deckler an extention to the report, how can I get the column next to the the new estimated delivery date where it can tell which associated Document number is used for the fulfilment of quantiy.
example-
In Backorder Table- the first few row are fulfilled by the first line of Open Puchase table. So, the associated Document number will be 229160 all the way through where 11/02/2022 and 230426 where 15/04 is in esti delivery column.
In Open Purchase table-
- Greg_Deckler4 years ago
Community Champion
learner03 Two ways based on the latest code from email. This version returns the last purchase order used to fulfill the backorder:
Purchase Orders Used = VAR __DaysToFulfill = 10 VAR __ItemCode = [Item Code] VAR __Simba = [Simba Ref#] VAR __Date = [Date] VAR __QtyToFulfill = SUMX( FILTER( 'Backorders', [Item Code] = __ItemCode && VALUE( TRUNC([Date]) & "." & RIGHT([Simba Ref#],LEN([Simba Ref#])-2)) <= VALUE( TRUNC(__Date) & "." & RIGHT(__Simba,LEN(__Simba)-2)) ), [Backorder Qty] ) VAR __Table = FILTER('On Purchase',[Item Code] = __ItemCode) VAR __Table1 = ADDCOLUMNS( ADDCOLUMNS(__Table,"__tqty",SUMX(FILTER(__Table,[ETA W/H] <= EARLIER([ETA W/H])),[Qty Balance])), "__LoopCounter",[__tqty] - __QtyToFulfill ) VAR __TargetDate = MINX(FILTER(__Table1, [__LoopCounter] >= 0),[ETA W/H]) VAR __FulfillmentDate = IF(__TargetDate = BLANK(),BLANK(),__TargetDate+__DaysToFulfill) RETURN MAXX(FILTER(__Table1,[ETA W/H] = __TargetDate),[Document Number])Here is one that preserves history so to speak:
Purchase Orders Used 2 = VAR __DaysToFulfill = 10 VAR __ItemCode = [Item Code] VAR __Simba = [Simba Ref#] VAR __Date = [Date] VAR __QtyToFulfill = SUMX( FILTER( 'Backorders', [Item Code] = __ItemCode && VALUE( TRUNC([Date]) & "." & RIGHT([Simba Ref#],LEN([Simba Ref#])-2)) <= VALUE( TRUNC(__Date) & "." & RIGHT(__Simba,LEN(__Simba)-2)) ), [Backorder Qty] ) VAR __Table = FILTER('On Purchase',[Item Code] = __ItemCode) VAR __Table1 = ADDCOLUMNS( ADDCOLUMNS(__Table,"__tqty",SUMX(FILTER(__Table,[ETA W/H] <= EARLIER([ETA W/H])),[Qty Balance])), "__LoopCounter",[__tqty] - __QtyToFulfill ) VAR __TargetDate = MINX(FILTER(__Table1, [__LoopCounter] >= 0),[ETA W/H]) VAR __FulfillmentDate = IF(__TargetDate = BLANK(),BLANK(),__TargetDate+__DaysToFulfill) RETURN CONCATENATEX(FILTER(__Table1,[ETA W/H] <= __TargetDate),[Document Number],", ")