I looked at this and didn't reply because my solution was so convoluted that I thought there
must be a more elegant formula (I still do!).
@mohamed ilyas' solution made me think that my formula wasn't so bad!
So in the attached, on
Sheet1 there's a single-celled formula at cell D2 (with hints for the arguments):
View attachment 88450
This is a named
lambda formula (
FruitSummary) which can be found in
Name Manager.
The development version of this formula is in cell G2 (which could be used if you didn't want to have a named formula), but this is for interest only and can be deleted.
Separately from all that, there's a
Power Query solution on sheet
PQ:
View attachment 88451
The query result (green table) is based on the grey table to the left. After adjusting/amending/adding to the grey table, the green table needs updating by right-clicking the green table and choosing
Refresh.