LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Average using lookup function


wrote in message
oups.com...
Bob Phillips wrote:
Maybe this is what you want
=SUM(SUMIF(INDIRECT({"B6:B19","B27:B40","H6:H19"}) ,"My
Product",INDIRECT({"C6:C19","C27:C40","I6:I19"})))/
SUM(COUNTIF(INDIRECT({"B6:B19","B27:B40","H6:H19"} ),"My Product"))


Great answer! I "knew" it was something "simple" like this, but I
didn't think of using INDIRECT to make it work. I think it only needs
to be noted that you are interpreting the OP to mean: average the
values in {C9:C19, C27:C40, I6:I19} corresponding to the values in
{B6:B19, B27:B40, H6:H19} that match "My Product". That is not what
the OP wrote; but I agree that that is probably what the OP meant.


I agree, the spec was a little ambiguous, so I made an assumption.
Unfortunately, as I am sure that you know, that is something that we (have
to) do very often in trying to give these solutions <g

One question.... Why do we need the extra SUM(....) around SUMIF and
COUNTIF? I know you are right, based on experiments. But I would have
thought that the SUMIF(...) and COUNTIF(...) alone would do the trick.
Is this simply an anomaly of Excel behavior? Or is there some good
reasoning for this behavior that escapes me?


The reason is that SUMIF and COUNTIF will not work directly with the array
of values (the non-contiguous ranges) that we are passing to SUMIF and
COUNTIF. By adding the SUM, that will, we effectively create multiple
SUMIF/COUNTIFs that get aggregated by SUM. I originally came up with this
technique using SUMPRODUCT, but someone pointed out to me that SUM does it
just as well, so I use that now.




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Average function question Sum Limit and marking Excel Worksheet Functions 4 July 8th 06 12:51 AM
Basing Average function range on Date? DangerMouse Excel Discussion (Misc queries) 4 June 20th 06 06:21 PM
average function Sum Limit and marking Excel Worksheet Functions 0 June 8th 06 04:49 PM
Calculate the average using the Lookup function or similar Lars F Excel Discussion (Misc queries) 2 November 22nd 05 11:40 AM
"Average" function query Robin Blackwell Excel Worksheet Functions 3 October 3rd 05 09:22 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"