PC Review


Reply
Thread Tools Rate Thread

Amending a Formula

 
 
Blake
Guest
Posts: n/a
 
      12th May 2011
I have the following formula and it works fine.

=AVERAGE(OFFSET($AH$14,COUNT($AH14:$AH5001)-1,,-14))

I want to amend this formula so that when I have O/A (Off/Average) in
column V it ignores that line as if it wasn't there and omits it from
the averages.

Thank you
 
Reply With Quote
 
 
 
 
joeu2004
Guest
Posts: n/a
 
      12th May 2011
On May 11, 4:03*pm, Blake <sfc...@gmail.com> wrote:
> I have the following formula and it works fine.
> =AVERAGE(OFFSET($AH$14,COUNT($AH14:$AH5001)-1,,-14))


I don't believe that. As written, you have a height of -14. But
height must positive.

Do you mean 14 instead of -14? Or did you mean "-1,-14" instead of
"-1,,-14"?

(For the future, it is best to copy-and-paste formulas from the
Formula Bar.)

Blake wrote:
> I want to amend this formula so that when I have O/A
> (Off/Average) in column V


How does column V factor into this?

If you meant to write "-1,-14", OFFSET returns the address of a single
cell column T, not column V. (And in that case, it would be better to
use INDEX, since that is non-volatile.)

If you meant to write "-1,,14", OFFSET returns a range in column AH.

Blake wrote:
> it ignores that line as if
> it wasn't there and omits it from the averages.


Note that AVERAGE automagically ignores empty cells (no constant, no
formula). If also ignores cells that contain text, such as the null
string ("") that makes a cell __appear__ blank, but it is not truly
empty.

If that is all you are worried about, there may be nothing you need to
do.

If these comments do not help, I suggest that you provide a concrete
example where your formula fails to give you what you want. Tell us
what it returns and what you want it to return. And of course, show
us the correct formula ;-).
 
Reply With Quote
 
isabelle
Guest
Posts: n/a
 
      12th May 2011
hi Blake,

named rng1
=OFFSET(Feuil1!$AH$14,,,COUNTA(Feuil1!$AH$14:$AH$5000))

and rng2
=OFFSET(Feuil1!$V$14,,,COUNTA(Feuil1!$V$14:$V$5000))


=SUMIF(rng2,"<>O/A",rng1)/COUNTIF(rng2,"<>O/A")

--
isabelle

 
Reply With Quote
 
Blake
Guest
Posts: n/a
 
      12th May 2011

> If these comments do not help, I suggest that you provide a concrete
> example where your formula fails to give you what you want. *Tell us
> what it returns and what you want it to return. *And of course, show
> us the correct formula ;-).


I did provide the correct formula. In fact I got it from someone
here.

=AVERAGE(OFFSET($AH$14,COUNT($AH14:$AH5001)-1,,-14))

Example:

A B
4
6
3 O/A
2
5
4 O/A
2


The current formula averages the last 14 days regardless of what is in
column B. What I want to do now is average the last 14 days unless an
O/A appears in column B. In that case it would skip (or throw out)
that line as if it didn't exist. (Columns are different on my
spreadsheet; this is just an example.)

 
Reply With Quote
 
Ken Mintz
Guest
Posts: n/a
 
      12th May 2011
On May 11, 6:04*pm, Blake <sfc...@gmail.com> wrote:
> I did provide the correct formula. *In fact I got it
> from someone here.
> =AVERAGE(OFFSET($AH$14,COUNT($AH14:$AH5001)-1,,-14))


That does not make it right. I am sure you can read the OFFSET help
page just as well as I can. It states: "Height must be a positive
number".

However, I always warn people that we cannot trust MS documentation.
I should have tried your formula myself and pointed out the
discrepancy between MS documentation and actual usage, instead of
taking the MS documentation for granted.

Although it is likely that the support of negative height is an
intentional feature, I try to avoid undocumented features if it is
just as easy not to rely on them. So I would use the following
formula:

=AVERAGE(OFFSET($AH$14,COUNT($AH14:$AH5001)-14,,14))

Blake wrote:
> Example:
> A * B
> 4
> 6
> 3 * O/A
> 2
> 5
> 4 * O/A
> 2
>
> The current formula averages the last 14 days regardless
> of what is in column B. *What I want to do now is average
> the last 14 days unless an O/A appears in column B. *In
> that case it would skip (or throw out) that line as if it
> didn't exist.


Perhaps the following __array_formula__[*]:

=AVERAGE(IF(OFFSET($B$14,COUNT($A14:$A5001)-14,,14))<>"o/a",
OFFSET($A$14,COUNT($A14:$A5001)-14,,14)))

But your requirements are ambiguously, IMHO.

That formula takes the last 14 non-empty cells in A14:A5001 and
excludes from the average any cells in those 14 that have "O/A" in the
corresponding cell in column B. So you might average fewer than 14
cells.

(In fact, you might average zero cells, in which case that formula
returns an Excel error. If you need help to avoid that error, the
ease of doing so depends on the version of Excel you are using. Which
one?)

That formula does __not__ average the last 14 non-empty cells in
A14:A5001 that do not have "O/A" in the corresponding cell in column
B. In other words, it does __not__ ensure that you average exactly 14
cells.

Which do you require?

To be clear, here is one that you might present your expectations
unambiguously.

Suppose A14:A100 contains numbers. The last 14 non-empty cells are
A87:A100. Suppose that only B88 and B95 contain "O/A".

Do you want effectively AVERAGE(A87,A89:A94,A96:A100)?

Or do you want effectively AVERAGE(A85:A87,A89:A94,A96:A100)?

The latter extends the "range" of cells to be averaged upward to
compensate for the cells that are ignored because of "O/A" in column
B. That is hard, IMHO.
 
Reply With Quote
 
KenM
Guest
Posts: n/a
 
      12th May 2011
On May 11, 6:04 pm, Blake <sfc...@gmail.com> wrote:
> I did provide the correct formula. In fact I got it
> from someone here.
> =AVERAGE(OFFSET($AH$14,COUNT($AH14:$AH5001)-1,,-14))


That does not make it right. As the OFFSET help page states: "Height
must be a positive
number".

However, I always warn people that we cannot trust MS documentation.

It is likely that the support of negative height is an
intentional feature. Nevertheless, I try to avoid undocumented
features if it is just as easy not to rely on them. So I would use
the following formula:

=AVERAGE(OFFSET($AH$14,COUNT($AH14:$AH5001)-14,,14))

Blake wrote:
> Example:
> A B
> 4
> 6
> 3 O/A
> 2
> 5
> 4 O/A
> 2


> The current formula averages the last 14 days regardless
> of what is in column B. What I want to do now is average
> the last 14 days unless an O/A appears in column B. In
> that case it would skip (or throw out) that line as if it
> didn't exist.


Perhaps the following __array_formula__[*]:

=AVERAGE(IF(OFFSET($B$14,COUNT($A14:$A5001)-14,,14))<>"o/a",
OFFSET($A$14,COUNT($A14:$A5001)-14,,14)))
[*] Enter an array formula by pressing ctrl+shift+Enter instead of
Enter. Excel will display an array formula surrounded by curly braces
in the Formula Bar, i.e. {=formula}. You cannot type the curly braces
yourself. If you make a mistake, select the cell, press F2 and edit,
then press ctrl+shift+Enter.

But your requirements are ambiguously, IMHO.

That formula takes the last 14 non-empty cells in A14:A5001 and
excludes from the average any cells in those 14 that have "O/A" in the
corresponding cell in column B. So you might average fewer than 14
cells.

(In fact, you might average zero cells, in which case that formula
returns an Excel error. If you need help to avoid that error, the
ease of doing so depends on the version of Excel you are using. Which
one?)

That formula does __not__ average the last 14 non-empty cells in
A14:A5001 that do not have "O/A" in the corresponding cell in column
B. In other words, it does __not__ ensure that you average exactly 14
cells.

Which do you require?

To be clear, here is one that you might present your expectations
unambiguously.

Suppose A14:A100 contains numbers. The last 14 non-empty cells are
A87:A100. Suppose that only B88 and B95 contain "O/A".

Do you want effectively AVERAGE(A87,A89:A94,A96:A100)?

Or do you want effectively AVERAGE(A85:A87,A89:A94,A96:A100)?

The latter extends the "range" of cells to be averaged upward to
compensate for the cells that are ignored because of "O/A" in column
B. That is hard, IMHO.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Amending Contacts gerryo Microsoft Outlook Discussion 1 23rd Mar 2010 11:14 PM
Amending a formula leerem Microsoft Excel Misc 3 4th Aug 2008 01:48 PM
Amending another formula leerem Microsoft Excel Misc 3 4th Aug 2008 10:54 AM
Amending Web Sites =?Utf-8?B?YW1vcw==?= Microsoft Frontpage 0 5th Jul 2006 11:20 AM
Help amending code Steve Microsoft Excel Misc 4 17th Aug 2005 03:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:21 AM.