google-sheetsgoogle-sheets-formulavlookupaccumulate

Lookup a value (in column) based on "Accumulated Sum" (or total) of QTY shipped column


enter image description here

Staff-A [Column A, row 2] "Fills" a Location with 50 QTY [Column B, row 2] at 12:00 [Column C, row 2]

From 12:05 to 12:30 [Column H] QTY are depleted from the Location [Column G] ...a total of 50 QTY have been depleted at 12:30 (from 12:05 to 12:30)

HOW DO I: "Lookup" the QTY [Column G] and "Intelligently" return the Time value (of 12:30) in [Column H, row 8]

NOTE: 5 QTY at 11:00 [Column G & H, row 2] is ignored - because they were depleted 'before' 12:00 [Column C]

ALSO, HOW DO I: "Lookup" the QTY [Column G] and return the Time value (of 12:20) in [Column H, row 6] ...for Staff B [Column A, row 3] who "Filled" the (same) Location with 20 QTY [Column B, row 3] at 12:15 [Column C, row 3]

VLOOKUP returns the first value (eg: 11:00) - however, I'm not sure how to tell VLOOKUP to 'sum' up the values (to equal the QTY filled) ...and then return that time value

enter image description here

Item Code Final DateTime Employee Number CubeRpln Deplete Time Item Code Final DateTime CubeRpln
1079613 4/3/2024 22:40:00 741044472 2.60 4/4/2024 3:04:35 1079613 4/3/2024 18:43:26 0.26
1079613 4/4/2024 2:20:00 741023458 1.56 4/4/2024 3:04:33 1079613 4/3/2024 21:18:22 0.26
1079613 4/4/2024 2:40:00 741044472 1.04 4/4/2024 3:04:32 1079613 4/3/2024 22:36:53 0.26
1083320 4/3/2024 14:00:00 741047084 2.52 4/3/2024 23:27:50 1079613 4/4/2024 0:02:08 0.26
1083320 4/3/2024 22:00:00 741080713 2.52 4/4/2024 3:09:30 1079613 4/4/2024 3:04:29 0.26
1140915 4/3/2024 20:40:00 741024943 4.40 1079613 4/4/2024 3:04:30 0.26
1079613 4/4/2024 3:04:31 0.26
1079613 4/4/2024 3:04:32 0.52
1079613 4/4/2024 3:04:33 0.26
1079613 4/4/2024 3:04:34 0.26
1079613 4/4/2024 3:04:35 0.52
1079613 4/4/2024 3:04:36 0.26
1079613 4/4/2024 3:46:37 0.52
1079613 4/4/2024 3:46:38 0.52
1079613 4/4/2024 3:46:39 0.52
1079613 4/4/2024 4:16:27 0.26
1079613 4/4/2024 4:16:28 0.26
1083320 4/3/2024 14:33:00 0.42
1083320 4/3/2024 14:33:04 0.42
1083320 4/3/2024 19:53:19 0.42
1083320 4/3/2024 19:53:25 0.42
1083320 4/3/2024 19:53:35 0.42
1083320 4/3/2024 23:27:50 0.42
1083320 4/3/2024 23:29:55 0.42
1083320 4/4/2024 0:59:37 0.42
1083320 4/4/2024 3:09:30 1.26
1083320 4/4/2024 3:09:35 0.42

enter image description here

https://docs.google.com/spreadsheets/d/13ymOatgYSTbPsoUddv2sOxtHhJHNtNmz4ldvCJm1uVE/edit

Added More "RealWorld" Data

enter image description here

Indicated in Column G whether [The Result] is correct


Solution

  • UPDATED FORMULA:

    =iferror(let(Σ,filter(I:J,H:H=B2), Λ,xmatch(C2,index(Σ,,1),1),
         Ξ,chooserows(Σ,sequence(max(1,rows(Σ)-Λ),1,Λ)),
         xlookup(E2,scan(,index(Ξ,,2),lambda(a,c,a+c)),index(Ξ,,1),,1)))
    

    enter image description here