Excuse the heavy title. Hi everyone

Essentially, I was trying to test the bounds of the nested IF function and I hit a wall. I wanted to run multiple cumulative frequency formulas in one.

Let me try and give an example:

Lets say I had a list of people, their favourite fruit, and how many they ate a week.

Name Fruit Amount Totals
Bob Bananas 10
Jill Apples 5
Jim Bananas 7
etc etc etc
I tried combining IF and IFERRORS together but I found I could only make it work if I had each fruit in a seperate column, not if I worked from one compiled master list. I tried to have it that IF this row contained "BANANAS" then it would add the previous row containing "BANANAS"'s total to the current amount, and if it didnt then I'd run the same formula for "APPLES", adding it to the previous row that contained apples, and so on.

Is there a way of housing all this in one complex nested formula rather than making my dataset bigger??