Forum Discussion
CrankyPants2382
Jul 25, 2023Copper Contributor
Return Date based on a sum of the total so far
Is there a formula that I could use that would return the date from a dataset based on a total so far for other conditions. A bit like a lookup but takes the sum so far into account. That's proba...
Patrick2788
Jul 27, 2023Silver Contributor
This function will return the date. All you have to do is provide 'condition' and the 'threshold' (e.g. 5 and 12).
'Picked Lambda
condition,threshold
=LET(
Accumulate, LAMBDA(a, v, a + v),
filtered, FILTER(data, TAKE(data, 1) = condition),
weather, TAKE(filtered, 1),
dates, TAKE(DROP(filtered, 1), 1),
apples, TAKE(filtered, -1),
total, SCAN(0, apples, Accumulate),
MIN(FILTER(dates, total >= threshold, 0))
)