Link to home
Start Free TrialLog in
Avatar of Richard Turner
Richard Turner

asked on

Excel Indirect Average Formula

I have a table in Excel with headings: Sep 18, Oct 18, Nov 18, etc.  I have a total row at the bottom too.

I want to use the indirect function that used given month to define which totals to average.  So for example, I might want an average of the last 3 months, or the last 6.

Depending on what I want to see, in cell E62 I have the value Jan 19 and a second cell (F62) with the value Oct 18.  Both are formatted as Custom Date fields as they are generated themselves by the eDate function.

I want my indirect function to then pick these up like this:
=AVERAGE(INDIRECT("SALESBYWEIGHT[[#Totals],["& E62 &"]:["& F62 &"]]"))
But I get a #REF! error.

Not quite sure what I'm doing wrong.

Thanks in advance.
Richard
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Peter Hall
Peter Hall

Richard, did you want to leave a space between your dates?  In other words could you try this:

=AVERAGE(INDIRECT("SALESBYWEIGHT[[#Totals],["&" TEXT(E62,"mmm-yy") "&"]:["&" TEXT(F62,"mmm-yy") "&"]]"))

The changes I made are in bold  Does this help?
Avatar of Richard Turner

ASKER

Thanks Norie, that worked a treat :)

Thank you for the suggestion Peter.  I tried it but Excel found an error with the formula.
You could also use the OFFSET function to create the range to be included in the Average.


=AVERAGE(OFFSET(Reference Point, Offset Rows, Offset Columns, Height, Width))

You would use the MATCH function to determine the position of the dates; the position of the first date would set the start position and the difference between the two matches would be number of columns to use.
Also as an aside, having the month as a column in a table seems out of kilter with standard data table configuration.

Normal data table config would be just one field/column entitled Date and the values in this column would then be the dates as per your headings and a value column for the monetary value.

With that config you could then use the AVERAGEIFS function with the criteria referring to the Date column and the Date cells defining the date range.

That data arrangement would also lend itself better to other functions, eg Pivot Tables or Slicers etc.