I have the challenge that my list will get every month new data. I need now to get the average of the last 6 months (where the cell is bigger than 0). My list gets every month new data and I need to get the average calculated for the last 6 months.
Example: In January I need the average in cell V2 of the last 6 months (means Jul-Dez column K-P) or the last 6 cells which are bigger than 0 in column H-S In February I need the average in cell V2 of the last 6 months (means Aug-Jan column L-Q) or the last 6 cells which are bigger than 0 in column H-S
Can someone help me?
Example list
I tried this:
=AVERAGE(TAKE(FILTER(H2:S2,ISNUMBER(H2:S2)),-6))
But that gives me not the result I need.
I have now tried this formula from @rory =AVERAGE(TAKE(FILTER(H2:S2,H2:S2>0),-6))
BUT when I add new data into Jan then I get a different average result (see picture below
The following assumes that your columns are H:S
and that your column headers are real EOM
dates that you show formatted as mmm-dd
TODAY()
CHOOSECOLS
create a list of all the entries in the row up to last monthFILTER
that row to remove any zero's, then average the last six (6).
Formula edited as column headers are "real dates" at EOM and not text strings
=LET(
cols, Sheet3!$H$1:$S$1,
lastCol, XLOOKUP(EOMONTH(TODAY(), -1), cols, cols),
chkRng, CHOOSECOLS(Sheet3!$H2:$S2, SEQUENCE(, XMATCH(lastCol, Sheet3!$H$1:$S$1, 0))),
notZero, FILTER(chkRng, chkRng <> 0),
avg, AVERAGE(TAKE(notZero, , -6)),
avg
)