0

I have row 1 containing some dates (undetermined number, because end formula will be a dynamic number) and I want row 5 to display the average of every column that has a date as a header.

Trying to have this array formula work :

arrayformula(iferror(
if(B1:1 = "",,
AVERAGE(
indirect(
SUBSTITUTE(ADDRESS(1,COLUMN(B1:1),4),"1","") 
& 7 & ":" & 
SUBSTITUTE(ADDRESS(1,COLUMN(B1:1),4),"1","")
)))))

I think I did isolate the problem in the arrayformula, I can't see where the problem lies with it ?

Here's a screenshot : enter image description here

and here's the link to the spreadsheet :

https://docs.google.com/spreadsheets/d/1GbIWwv0lq6nVdn4dHkSO0-QqZYEPCwJtntCu8wcSd9Q/edit?usp=sharing

1 Answer 1

2

QUERY method:

=ArrayFormula(IF(B1:1="",,IFERROR(VLOOKUP(COLUMN(B1:1),QUERY(SPLIT(FLATTEN(TRANSPOSE(COLUMN(B7:7)&"♦"&B7:1000)),"♦"),"select Col1,avg(Col2) where Col2 is not null group by Col1 label avg(Col2) ''",0),2,FALSE),)))

MMULT method:

=ArrayFormula(IF(B1:1="",,IFERROR(MMULT(N(TRANSPOSE(ROW(B7:1000)^0)),N(B7:1000))/MMULT(N(TRANSPOSE(ROW(B7:1000)^0)),N(B7:1000<>"")),)))
Sign up to request clarification or add additional context in comments.

7 Comments

ty it works ... but ... It's painfully slow, especially for a simplified test page : I did several tests and it takes about 7 seconds to update. I'm afraid it might get too slow on the production file. I will make some more tests. Thanks for your help !
it takes about 10 seconds to update the production sheet. I hope someone comes with a faster solution. Do you think my approach is wrong and cannot be used with somewhat slight corrections / modifications ? I will either use it if the delay is acceptable for the users, or if no one has a better solution, make it a script.
Added another method, please check.
ty : I will need to understand what you're doing here :-) It works well, but it doesn't work into the production sheet, so I tried to duplicate the test sheet (same data exactly in the same reference cells) and the exact same formula, but also get a blank result, with no error message. I'm puzzled ...
Edit : a pure duplicate of the sheet produces the expected result, but rebuilding another sheet with the same data and same formula in the same cells doesn't work.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.