This is my Items sheet
And this is my Values sheet
As can be seen from the table, alfa is associated with 20 40 60 80, beta with 30 40 70 80 and gamma with 50 60 70 80.
In the Items sheet in cell B1 (next to the first item) I would like a formula (Arrayformula or alike) generating the average value for each item. In my example it should be:
alfa -> 50 (that is: (20 40 60 80)/4 = 200/4)
beta -> 55 (that is: (30 40 70 80)/4 = 220/4)
gamma-> 65 (that is: (50 60 70 80)/4 = 260/4)
So the final result should be:
update
=IFERROR(BYROW(A1:INDEX(A:A, MAX(ROW(A:A)*(A:A<>""))),
LAMBDA(x, INDEX(QUERY(SPLIT(FLATTEN(
FILTER(Values!A:C, Values!D:D<>"")&""&
FILTER(Values!D:D, Values!D:D<>"")), ""),
"select avg(Col2) where Col1 = '"&x&"'"), 2))))