I am trying to get a way to apply some function to values in a table where the descriptor is in an array of unique descriptors.
For example, averaging all of the values for a unique descriptor. However, I have the unique array function, so I would like to just apply it to all of the values given by an array given by vlookup.
I would like this formula working as an array formula (input in one cell that creates the length of array that is required, rather than having to copy an unknown amount of rows)
=ARRAYFORMULA(AVERAGEIFS(values_to_avg,descriptors,UNIQUE(descriptors)))
or, for a more general solution, we would like something which can take different functions than average - my poor attempt was this:
=ARRAYFORMULA(AVERAGE(ARRAYFORMULA(VLOOKUP(UNIQUE(descriptors),CHOOSE({1,2},descriptors, values_to_avg), 2,0))))
So, my hope was to VLOOKUP all the values for a unique descriptor, where the range has been rearranged by CHOOSE. Now we want all the values where this unique desirptor is, so we have to use ARRAYFORMULA around that. Then we want the average of all of these values, but for each unique desriptor, so we need another arrayformula around that.
However, this does not work.
So I am unsure of how to nest array formulas with VLOOKUPs or FILTERs.
Does anyone have suggestions to get this with an arrayformula?
EXAMPLE:
I have two columns of expermental data or user input:

and I would like to get an array of the averages for all of the unique values. Something like this:
=ARRAYFORMULA(AVERAGEIFS($A$2:$A,$B$2:$B,UNIQUE($B$2:$B)))
or this:
=ARRAYFORMULA(AVERAGE(arrayformula(VLOOKUP(UNIQUE($B$2:$B),CHOOSE({1,2},$B$2:$B, $A$2:$A), 2,0))))
Can this nested array formula function work?