excel - Optimization of array function that calculates products -
excel - Optimization of array function that calculates products -
i have next array formula calculates returns on particular stock in particular year:
=if(and(not(e2=e3),h2=h3),product(if($e$2:e2=e1,$o$2:o2,""))-1,"") but since have 500,000 row entries nail row 50,000 error excel stating machine not have plenty resources compute values.
how shall optimize function works?
e column refers counter check years , ticker values of stocks. if year different previous value function output 1. output 1 when name of stock has changed. illustration may have values year 1993 , next value 1993 name of stock different, homecoming should calculated anew, , utilize 1 indication that.
then have column runs cumulative sum of 1s. when new 1 in previous column encountered add together 1 running total , maintain printing same number until observe new one. makes possible utilize of array function, if column contains running total values (e column) has next value different previous utilize twist on sumif product if. homecoming product of corresponding running total e column values.
the source of inefficiency, believe, in steady increment row number of number of cells must examined in order evaluate each successive array formula. in row 50,000, example, formula must examine cells in rows above it.
i'm big fan of array formulas, pains me this, wouldn't way. instead, utilize additional columns compute, in each row, pieces of formula needed homecoming desired result. taking approach, you're exploiting excel's efficient recalculation engine compute what's needed.
as final product, compute cumulative running product in auxiliary column, , resets value in column o when column p in row above contains number. approach much more "local" , avoids formulas depend on big numbers of cells.
i realize text not best language describing this, , poor writing skills might adding challenge, please allow me know if more detail needed.
interesting problem, thanks.
arrays excel function optimization
Comments
Post a Comment