Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Excel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-13-2008, 09:12 AM
Harry Flashman
 
Posts: n/a
Problems referencing dates with the MATCH formula

I am finding this a little unpredictable. Sometimes it works fine; for
example:
A B C D
Date Mar-08 Feb-08 Jan-08

If I wish to return the column number from the dates:
Mar-08 =MATCH(A2,$A$1:$D$1) returns the value 2
Feb-08 =MATCH(A3,$A$1:$D$1) returns the value 3
Jan-08 =MATCH(A4,$A$1:$D$1) returns the value 4

However if I expand the reference to include column E, Dec-07 I get
this result:
Mar-08 =MATCH(A2,$A$1:$E$1) returns the value 5 (which is the total
number of cells in the reference).

Can anyone explain why this would be the case?
(The dates are actually 01/03/2008 (UK style) but I have used custom
format to display them as mmm-yy. Also the dates are always the first
of the month.)

Then next part of my question is a little more complex.

In column A I have a product names
In column B I have the first date that this product was sold.
In Column D to A I have the product sales by month.
I would like to use the AVERAGE formula in in column C to calculate
the average sales over time.
However not all products have the same history; some are more recent
than others; products have the value zero in the months before they
appeared.
Therefore if a product has been around since the start the formula
will be =AVERAGE(D2:Z2)
But if the product has only been around for the past three months the
formula will be =AVERAGE(D2:F2)

I would like to use the MATCH formula (or a similar formula) to
replace the second cell reference in my AVERAGE formula. That is, a
nested formula that references the values in column B (the date the
product was first sold) and returns the appropriate column reference.

I hope I have been clear. Can anyone help with either of these
question? I would be eternally grateful.

Harry
Reply With Quote
  #2 (permalink)  
Old 05-13-2008, 09:26 AM
Ed Ferrero
 
Posts: n/a
Re: Problems referencing dates with the MATCH formula

Hi Harry,

Try using =MATCH(A2,$A$1:$E$1,0)

From help;
If match_type is omitted, it is assumed to be 1.

If match_type is 1, MATCH finds the largest value that is less than or equal
to lookup_value. Lookup_array must be placed in ascending order: ...-2, -1,
0, 1, 2, ..., A-Z, FALSE, TRUE.

If match_type is 0, MATCH finds the first value that is exactly equal to
lookup_value. Lookup_array can be in any order.

Ed Ferrero
www.edferrero.com

Reply With Quote
  #3 (permalink)  
Old 05-13-2008, 09:36 AM
Harry Flashman
 
Posts: n/a
Re: Problems referencing dates with the MATCH formula

On May 13, 6:26*pm, "Ed Ferrero" <ed@edferrero_remove_.com> wrote:
> Hi Harry,
>
> Try using =MATCH(A2,$A$1:$E$1,0)
>
> From help;
> If match_type is omitted, it is assumed to be 1.
>
> If match_type is 1, MATCH finds the largest value that is less than or equal
> to lookup_value. Lookup_array must be placed in ascending order: ...-2, -1,
> 0, 1, 2, ..., A-Z, FALSE, TRUE.
>
> If match_type is 0, MATCH finds the first value that is exactly equal to
> lookup_value. Lookup_array can be in any order.
>
> Ed Ferrerowww.edferrero.com


Thank you very much for answering the first part of my question. Yes
that did the trick.
Reply With Quote
  #4 (permalink)  
Old 05-13-2008, 09:37 AM
Pete_UK
 
Posts: n/a
Re: Problems referencing dates with the MATCH formula

Try setting the third parameter of the MATCH function to zero, to
ensure that you are looking for an exact match, i.e.:

=MATCH(A2,$A$1:$E$1,0)

In answer to your second question, you can use this array* formula:

=AVERAGE(IF(D2:Z2<>0,D2:Z2))

which will only count non-zero entries in the average.

* An array formula has to be committed using the key combination of
CTRL-SHIFT-ENTER (CSE) instead of the usual ENTER. If you do this
correctly then Excel will wrap curly braces { } around the formula
when viewed in the formula bar - you should not type these yourself.

Another way of avoiding counting the zeros in the average is to use
COUNTIF:

=SUM(D2:Z2)/COUNTIF(D2:Z2,">0")

or if you really want to use a MATCH function to adjust the range of
the AVERAGE function, then you will have to do so within an INDIRECT
function.

Hope this helps.

Pete

On May 13, 9:12*am, Harry Flashman <flashdav...@gmail.com> wrote:
> I am finding this a little unpredictable. Sometimes it works fine; for
> example:
> A * * * * B * * * * * C * * * * *D
> Date * * Mar-08 * Feb-08 *Jan-08
>
> If I wish to return the column number from the dates:
> Mar-08 *=MATCH(A2,$A$1:$D$1) *returns the value 2
> Feb-08 *=MATCH(A3,$A$1:$D$1) *returns the value 3
> Jan-08 * =MATCH(A4,$A$1:$D$1) *returns the value 4
>
> However if I expand the reference to include column E, Dec-07 I get
> this result:
> Mar-08 *=MATCH(A2,$A$1:$E$1) *returns the value 5 (which is the total
> number of cells in the reference).
>
> Can anyone explain why this would be the case?
> (The dates are actually 01/03/2008 (UK style) but I have used custom
> format to display them as mmm-yy. Also the dates are always the first
> of the month.)
>
> Then next part of my question is a little more complex.
>
> In column A I have a product names
> In column B I have the first date that this product was sold.
> In Column D to A I have the product sales by month.
> I would like to use the AVERAGE formula in in column C to calculate
> the average sales over time.
> However not all products have the same history; some are more recent
> than others; products have the value zero in the months before they
> appeared.
> Therefore if a product has been around since the start the formula
> will be =AVERAGE(D2:Z2)
> But if the product has only been around for the past three months the
> formula will be =AVERAGE(D2:F2)
>
> I would like to use the MATCH formula (or a similar formula) to
> replace the second cell reference in my AVERAGE formula. That is, a
> nested formula that references the values in column B (the date the
> product was first sold) and returns the appropriate column reference.
>
> I hope I have been clear. Can anyone help with either of these
> question? I would be eternally grateful.
>
> Harry


Reply With Quote
  #5 (permalink)  
Old 05-13-2008, 09:47 AM
Harry Flashman
 
Posts: n/a
Re: Problems referencing dates with the MATCH formula

On May 13, 6:37*pm, Pete_UK <pashu...@auditel.net> wrote:
> Try setting the third parameter of the MATCH function to zero, to
> ensure that you are looking for an exact match, i.e.:
>
> =MATCH(A2,$A$1:$E$1,0)
>
> In answer to your second question, you can use this array* formula:
>
> =AVERAGE(IF(D2:Z2<>0,D2:Z2))
>
> which will only count non-zero entries in the average.
>
> * An array formula has to be committed using the key combination of
> CTRL-SHIFT-ENTER (CSE) instead of the usual ENTER. If you do this
> correctly then Excel will wrap curly braces { } around the formula
> when viewed in the formula bar - you should not type these yourself.
>
> Another way of avoiding counting the zeros in the average is to use
> COUNTIF:
>
> =SUM(D2:Z2)/COUNTIF(D2:Z2,">0")
>
> or if you really want to use a MATCH function to adjust the range of
> the AVERAGE function, then you will have to do so within an INDIRECT
> function.
>
> Hope this helps.
>
> Pete
>
> On May 13, 9:12*am, Harry Flashman <flashdav...@gmail.com> wrote:
>
>
>
> > I am finding this a little unpredictable. Sometimes it works fine; for
> > example:
> > A * * * * B * * * * * C * * * * *D
> > Date * * Mar-08 * Feb-08 *Jan-08

>
> > If I wish to return the column number from the dates:
> > Mar-08 *=MATCH(A2,$A$1:$D$1) *returns the value 2
> > Feb-08 *=MATCH(A3,$A$1:$D$1) *returns the value 3
> > Jan-08 * =MATCH(A4,$A$1:$D$1) *returns the value 4

>
> > However if I expand the reference to include column E, Dec-07 I get
> > this result:
> > Mar-08 *=MATCH(A2,$A$1:$E$1) *returns the value 5 (which is the total
> > number of cells in the reference).

>
> > Can anyone explain why this would be the case?
> > (The dates are actually 01/03/2008 (UK style) but I have used custom
> > format to display them as mmm-yy. Also the dates are always the first
> > of the month.)

>
> > Then next part of my question is a little more complex.

>
> > In column A I have a product names
> > In column B I have the first date that this product was sold.
> > In Column D to A I have the product sales by month.
> > I would like to use the AVERAGE formula in in column C to calculate
> > the average sales over time.
> > However not all products have the same history; some are more recent
> > than others; products have the value zero in the months before they
> > appeared.
> > Therefore if a product has been around since the start the formula
> > will be =AVERAGE(D2:Z2)
> > But if the product has only been around for the past three months the
> > formula will be =AVERAGE(D2:F2)

>
> > I would like to use the MATCH formula (or a similar formula) to
> > replace the second cell reference in my AVERAGE formula. That is, a
> > nested formula that references the values in column B (the date the
> > product was first sold) and returns the appropriate column reference.

>
> > I hope I have been clear. Can anyone help with either of these
> > question? I would be eternally grateful.

>
> > Harry- Hide quoted text -

>
> - Show quoted text -


Thank for your advice which I am sure I will have call to use some
time.
In this case I would like to include the zeros. The only zero's I do
not want to include are the zeros that are there because the product
had not yet been released.
I had a feeling that I would need to use the INDIRECT formula in some
way, but I am not sure how to use it. I'll try reading some more,
thank you.

=AVERAGE(D2:INDIRECT(....

Will it look something like the above?
Reply With Quote
  #6 (permalink)  
Old 05-13-2008, 10:13 AM
Pete_UK
 
Posts: n/a
Re: Problems referencing dates with the MATCH formula

It will look something like:

=AVERAGE(INDIRECT("D2:" &
your_match_function_turning_col_number_to_letter & "2"))

As you are only interested in up to column Z, you can use the CHAR
function to convert the match number to a letter.

Hope this helps.

Pete

On May 13, 9:47*am, Harry Flashman <flashdav...@gmail.com> wrote:
> On May 13, 6:37*pm, Pete_UK <pashu...@auditel.net> wrote:
>
>
>
>
>
> > Try setting the third parameter of the MATCH function to zero, to
> > ensure that you are looking for an exact match, i.e.:

>
> > =MATCH(A2,$A$1:$E$1,0)

>
> > In answer to your second question, you can use this array* formula:

>
> > =AVERAGE(IF(D2:Z2<>0,D2:Z2))

>
> > which will only count non-zero entries in the average.

>
> > * An array formula has to be committed using the key combination of
> > CTRL-SHIFT-ENTER (CSE) instead of the usual ENTER. If you do this
> > correctly then Excel will wrap curly braces { } around the formula
> > when viewed in the formula bar - you should not type these yourself.

>
> > Another way of avoiding counting the zeros in the average is to use
> > COUNTIF:

>
> > =SUM(D2:Z2)/COUNTIF(D2:Z2,">0")

>
> > or if you really want to use a MATCH function to adjust the range of
> > the AVERAGE function, then you will have to do so within an INDIRECT
> > function.

>
> > Hope this helps.

>
> > Pete

>
> > On May 13, 9:12*am, Harry Flashman <flashdav...@gmail.com> wrote:

>
> > > I am finding this a little unpredictable. Sometimes it works fine; for
> > > example:
> > > A * * * * B * * * * * C * * * * *D
> > > Date * * Mar-08 * Feb-08 *Jan-08

>
> > > If I wish to return the column number from the dates:
> > > Mar-08 *=MATCH(A2,$A$1:$D$1) *returns the value 2
> > > Feb-08 *=MATCH(A3,$A$1:$D$1) *returns the value 3
> > > Jan-08 * =MATCH(A4,$A$1:$D$1) *returns the value 4

>
> > > However if I expand the reference to include column E, Dec-07 I get
> > > this result:
> > > Mar-08 *=MATCH(A2,$A$1:$E$1) *returns the value 5 (which is the total
> > > number of cells in the reference).

>
> > > Can anyone explain why this would be the case?
> > > (The dates are actually 01/03/2008 (UK style) but I have used custom
> > > format to display them as mmm-yy. Also the dates are always the first
> > > of the month.)

>
> > > Then next part of my question is a little more complex.

>
> > > In column A I have a product names
> > > In column B I have the first date that this product was sold.
> > > In Column D to A I have the product sales by month.
> > > I would like to use the AVERAGE formula in in column C to calculate
> > > the average sales over time.
> > > However not all products have the same history; some are more recent
> > > than others; products have the value zero in the months before they
> > > appeared.
> > > Therefore if a product has been around since the start the formula
> > > will be =AVERAGE(D2:Z2)
> > > But if the product has only been around for the past three months the
> > > formula will be =AVERAGE(D2:F2)

>
> > > I would like to use the MATCH formula (or a similar formula) to
> > > replace the second cell reference in my AVERAGE formula. That is, a
> > > nested formula that references the values in column B (the date the
> > > product was first sold) and returns the appropriate column reference.

>
> > > I hope I have been clear. Can anyone help with either of these
> > > question? I would be eternally grateful.

>
> > > Harry- Hide quoted text -

>
> > - Show quoted text -

>
> Thank for your advice which I am sure I will have call to use some
> time.
> In this case I would like to include the zeros. The only zero's I do
> not want to include are the zeros that are there because the product
> had not yet been released.
> I had a feeling that I would need to use the INDIRECT formula in some
> way, but I am not sure how to use it. I'll try reading some more,
> thank you.
>
> =AVERAGE(D2:INDIRECT(....
>
> Will it look something like the above?- Hide quoted text -
>
> - Show quoted text -


Reply With Quote
  #7 (permalink)  
Old 05-13-2008, 10:26 AM
Harry Flashman
 
Posts: n/a
Re: Problems referencing dates with the MATCH formula

On May 13, 7:13*pm, Pete_UK <pashu...@auditel.net> wrote:
> It will look something like:
>
> =AVERAGE(INDIRECT("D2:" &
> your_match_function_turning_col_number_to_letter & "2"))
>
> As you are only interested in up to column Z, you can use the CHAR
> function to convert the match number to a letter.
>
> Hope this helps.
>
> Pete
>
> On May 13, 9:47*am, Harry Flashman <flashdav...@gmail.com> wrote:
>
>
>
> > On May 13, 6:37*pm, Pete_UK <pashu...@auditel.net> wrote:

>
> > > Try setting the third parameter of the MATCH function to zero, to
> > > ensure that you are looking for an exact match, i.e.:

>
> > > =MATCH(A2,$A$1:$E$1,0)

>
> > > In answer to your second question, you can use this array* formula:

>
> > > =AVERAGE(IF(D2:Z2<>0,D2:Z2))

>
> > > which will only count non-zero entries in the average.

>
> > > * An array formula has to be committed using the key combination of
> > > CTRL-SHIFT-ENTER (CSE) instead of the usual ENTER. If you do this
> > > correctly then Excel will wrap curly braces { } around the formula
> > > when viewed in the formula bar - you should not type these yourself.

>
> > > Another way of avoiding counting the zeros in the average is to use
> > > COUNTIF:

>
> > > =SUM(D2:Z2)/COUNTIF(D2:Z2,">0")

>
> > > or if you really want to use a MATCH function to adjust the range of
> > > the AVERAGE function, then you will have to do so within an INDIRECT
> > > function.

>
> > > Hope this helps.

>
> > > Pete

>
> > > On May 13, 9:12*am, Harry Flashman <flashdav...@gmail.com> wrote:

>
> > > > I am finding this a little unpredictable. Sometimes it works fine; for
> > > > example:
> > > > A * * * * B * * * * * C * * * * *D
> > > > Date * * Mar-08 * Feb-08 *Jan-08

>
> > > > If I wish to return the column number from the dates:
> > > > Mar-08 *=MATCH(A2,$A$1:$D$1) *returns the value 2
> > > > Feb-08 *=MATCH(A3,$A$1:$D$1) *returns the value 3
> > > > Jan-08 * =MATCH(A4,$A$1:$D$1) *returns the value 4

>
> > > > However if I expand the reference to include column E, Dec-07 I get
> > > > this result:
> > > > Mar-08 *=MATCH(A2,$A$1:$E$1) *returns the value 5 (which is the total
> > > > number of cells in the reference).

>
> > > > Can anyone explain why this would be the case?
> > > > (The dates are actually 01/03/2008 (UK style) but I have used custom
> > > > format to display them as mmm-yy. Also the dates are always the first
> > > > of the month.)

>
> > > > Then next part of my question is a little more complex.

>
> > > > In column A I have a product names
> > > > In column B I have the first date that this product was sold.
> > > > In Column D to A I have the product sales by month.
> > > > I would like to use the AVERAGE formula in in column C to calculate
> > > > the average sales over time.
> > > > However not all products have the same history; some are more recent
> > > > than others; products have the value zero in the months before they
> > > > appeared.
> > > > Therefore if a product has been around since the start the formula
> > > > will be =AVERAGE(D2:Z2)
> > > > But if the product has only been around for the past three months the
> > > > formula will be =AVERAGE(D2:F2)

>
> > > > I would like to use the MATCH formula (or a similar formula) to
> > > > replace the second cell reference in my AVERAGE formula. That is, a
> > > > nested formula that references the values in column B (the date the
> > > > product was first sold) and returns the appropriate column reference..

>
> > > > I hope I have been clear. Can anyone help with either of these
> > > > question? I would be eternally grateful.

>
> > > > Harry- Hide quoted text -

>
> > > - Show quoted text -

>
> > Thank for your advice which I am sure I will have call to use some
> > time.
> > In this case I would like to include the zeros. The only zero's I do
> > not want to include are the zeros that are there because the product
> > had not yet been released.
> > I had a feeling that I would need to use the INDIRECT formula in some
> > way, but I am not sure how to use it. I'll try reading some more,
> > thank you.

>
> > =AVERAGE(D2:INDIRECT(....

>
> > Will it look something like the above?- Hide quoted text -

>
> > - Show quoted text -- Hide quoted text -

>
> - Show quoted text -


Thank you very much that is a big help. But in fact I actually go up
to column BD. My example was simplified.
Can I still use the MATCH function in someway here?
Reply With Quote
  #8 (permalink)  
Old 05-13-2008, 10:35 AM
Pete_UK
 
Posts: n/a
Re: Problems referencing dates with the MATCH formula

I'm a bit confused about the column references you are using. In your
first example you just mentioned about columns A to E, then you
mentioned a range from D to Z, and now you talk about going up to BD -
that's why I didn't actually give you a formula to do this. If you can
spell out exactly how your data is laid out then I might be able to
quote a formula to do it.

Pete

On May 13, 10:26*am, Harry Flashman <flashdav...@gmail.com> wrote:
>
> Thank you very much that is a big help. But in fact I actually go up
> to column BD. My example was simplified.
> Can I still use the MATCH function in someway here

Reply With Quote
  #9 (permalink)  
Old 05-13-2008, 11:02 AM
Harry Flashman
 
Posts: n/a
Re: Problems referencing dates with the MATCH formula

On May 13, 7:35*pm, Pete_UK <pashu...@auditel.net> wrote:
> I'm a bit confused about the column references you are using. In your
> first example you just mentioned about columns A to E, then you
> mentioned a range from D to Z, and now you talk about going up to BD -
> that's why I didn't actually give you a formula to do this. If you can
> spell out exactly how your data is laid out then I might be able to
> quote a formula to do it.
>
> Pete
>
> On May 13, 10:26*am, Harry Flashman <flashdav...@gmail.com> wrote:
>
>
>
>
>
> > Thank you very much that is a big help. But in fact I actually go up
> > to column BD. My example was simplified.
> > Can I still use the MATCH function in someway here- Hide quoted text -

>
> - Show quoted text -


I am sorry Pete. You have actually been a big help and you have helped
improve my understanding a lot.
I tried to keep my example simple. Also I made a typo in my first
post.
"In Column D to A I have the product sales by month." It should not
have ben D to A.
I meant "Column D to Z I have product sales by month".
In my real speadsheet I actually have Column D to BD, that is months
Mar-08 to Dec-03.
Column A contains the names of the products.
Column B contains the months the product was first sold (format mmm-
yy)
Column C contains the average monthly sales from the time that the
specific product was first sold. The first date of sale varies from
product to product.
Column D to BD is the months (format mmm-yy)

Put simply I am calculating the average sales of each product. But I
need something a little more sophisticated than just =AVERAGE(D:BD)
because not all products went on sale for the first time at the same
time.

The array formula you provided would be okay except that in some
months a product may sell zero. I still want to include that zero in
my average.



Reply With Quote
  #10 (permalink)  
Old 05-13-2008, 11:23 AM
Pete_UK
 
Posts: n/a
Re: Problems referencing dates with the MATCH formula

Okay, with that layout this formula will return the column ID as a
letter (or letters):

=IF(MATCH(B2,D$1:BD$1,0)+3>26,CHAR(INT((MATCH(B2,D $1:BD$1,0)+2)/
26)+64),"")&CHAR(MOD(MATCH(B2,D$1:BD$1,0)+2,26)+65 )

(I'm sure there must be a better way, but this works for now!!)

So, your average formula will be (in C2):

=AVERAGE(INDIRECT("D"&ROW(C2)&":"&IF(MATCH(B2,D$1: BD
$1,0)+3>26,CHAR(INT((MATCH(B2,D$1:BD$1,0)+2)/
26)+64),"")&CHAR(MOD(MATCH(B2,D$1:BD$1,0)+2,26)+65 )&ROW(C2)))

I've had to use the ROW function in order for the row reference to
increment as you copy the formula down - it doesn't matter what
reference is actually in there, though I've used C2.

So, copy this down and it should give you what you want - obviously,
if you have no values in columns D to BD then you will get #DIV/0
error, and if you have no date in column B you will get the #N/A
error, so you might want to trap these before copying down.

Hope this helps.

Pete


On May 13, 11:02*am, Harry Flashman <flashdav...@gmail.com> wrote:
>
> I am sorry Pete. You have actually been a big help and you have helped
> improve my understanding a lot.
> I tried to keep my example simple. Also I made a typo in my first
> post.
> "In Column D to A I have the product sales by month." It should not
> have ben D to A.
> I meant "Column D to Z I have product sales by month".
> In my real speadsheet I actually have Column D to BD, that is months
> Mar-08 to Dec-03.
> Column A contains the names of the products.
> Column B contains the months the product was first sold (format mmm-
> yy)
> Column C contains the average monthly sales from the time that the
> specific product was first sold. The first date of sale varies from
> product to product.
> Column D to BD is the months (format mmm-yy)
>
> Put simply I am calculating the average sales of each product. But I
> need something a little more sophisticated than just =AVERAGE(D:BD)
> because not all products went on sale for the first time at the same
> time.
>
> The array formula you provided would be okay except that in some
> months a product may sell zero. I still want to include that zero in
> my average

Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Excel


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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



All times are GMT. The time now is 05:16 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Mortgages | Personal Car Finance | Mortgage | Personal Loans | Per Insurance



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114