Forum Discussion

CBritsNZ's avatar
CBritsNZ
Occasional Reader
Mar 10, 2025
Solved

Calculation of values based on the next occurrence of a criteria

I am looking to create a formula to sum an amount between 2 rows based on the next occurrence if a criteria. in the below example.  the criteria will be to look for "apple".  my values are located in a table.

  • between the 1 occurrence and next there is no amount values, hence the sum value needs to be 0. 
  • then between 2nd and 3rd occurrence the formula needs to sum all amount values for a,b,c,d,e.
  • then between 3rd and 4th occurrence the formula needs to sum all amounts for a,b,c,d,e,f,g,h

this continues down

  • for the last sum 'block' it needs to sum the values from the last occurrence of "apple' to the end of the table
 Amountsum value
apple 0
apple 25
a5 
b3 
c2 
d10 
e5 
apple 53
a2 
b1 
c4 
d5 
PLUM  
e10 
f6 
g15 
h10 
Apple 25
a2 
b4 
c7 
d9 
e2 
f1 
apple 19
a5 
b8 
c3 
d1 
e2 
f7 

Resources