Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Darla
 
Posts: n/a
Default average if function

I need to average the cost per lb if a string starts with...my spread sheet
is 640 rows long with over 10 averages needed.

I know how to do the formula except how to say "starts with" instead of "="
the string is quite long but I only need to reference the first part of it
"tu or ana36"
example below
TU SQRPR INB000160032000384000000200000000
ANA36 BAR INB000160001600002000000200000000
ANA36 BAR INB000160001600004000000200000000


  #2   Report Post  
Peo Sjoblom
 
Posts: n/a
Default

=AVERAGE(IF(LEFT(A2:A640,2)="TU",B2:B640))

entered with ctrl + shift & enter

for TU
--

Regards,

Peo Sjoblom


"Darla" wrote in message
...
I need to average the cost per lb if a string starts with...my spread

sheet
is 640 rows long with over 10 averages needed.

I know how to do the formula except how to say "starts with" instead of

"="
the string is quite long but I only need to reference the first part of it
"tu or ana36"
example below
TU SQRPR INB000160032000384000000200000000
ANA36 BAR INB000160001600002000000200000000
ANA36 BAR INB000160001600004000000200000000




  #3   Report Post  
Peo Sjoblom
 
Posts: n/a
Default

If you meant either of TU or ANA36

=AVERAGE(IF((LEFT(A2:A640,2)="TU")+(LEFT(A2:A640,5 )="ANA36"),B2:B640))

also array entrered


--

Regards,

Peo Sjoblom


"Peo Sjoblom" wrote in message
...
=AVERAGE(IF(LEFT(A2:A640,2)="TU",B2:B640))

entered with ctrl + shift & enter

for TU
--

Regards,

Peo Sjoblom


"Darla" wrote in message
...
I need to average the cost per lb if a string starts with...my spread

sheet
is 640 rows long with over 10 averages needed.

I know how to do the formula except how to say "starts with" instead of

"="
the string is quite long but I only need to reference the first part of

it
"tu or ana36"
example below
TU SQRPR INB000160032000384000000200000000
ANA36 BAR INB000160001600002000000200000000
ANA36 BAR INB000160001600004000000200000000






  #4   Report Post  
Bob Phillips
 
Posts: n/a
Default

or even

=AVERAGE(IF(OR(LEFT(A2:A640,2)="TU"),(LEFT(A2:A640 ,5)="ANA36")),B2:B640)

array entered.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Peo Sjoblom" wrote in message
...
If you meant either of TU or ANA36

=AVERAGE(IF((LEFT(A2:A640,2)="TU")+(LEFT(A2:A640,5 )="ANA36"),B2:B640))

also array entrered


--

Regards,

Peo Sjoblom


"Peo Sjoblom" wrote in message
...
=AVERAGE(IF(LEFT(A2:A640,2)="TU",B2:B640))

entered with ctrl + shift & enter

for TU
--

Regards,

Peo Sjoblom


"Darla" wrote in message
...
I need to average the cost per lb if a string starts with...my spread

sheet
is 640 rows long with over 10 averages needed.

I know how to do the formula except how to say "starts with" instead

of
"="
the string is quite long but I only need to reference the first part

of
it
"tu or ana36"
example below
TU SQRPR INB000160032000384000000200000000
ANA36 BAR INB000160001600002000000200000000
ANA36 BAR INB000160001600004000000200000000








  #5   Report Post  
Harlan Grove
 
Posts: n/a
Default

Peo Sjoblom wrote...
If you meant either of TU or ANA36

=AVERAGE(IF((LEFT(A2:A640,2)="TU")+(LEFT(A2:A640, 5)="ANA36"),B2:B640))

....

Which means you're comparing A2:A640 to both TU and ANA36. One way
around that would be

=AVERAGE(IF(LEFT(A2:A640,2)="TU",1,LEFT(A2:A640,5) ="ANA36"),B2:B640)

Another alternative, which scales better if there were several more
values to match, would be

=SUM(SUMIF(A2:A640,{"TU","ANA36"}&"*",B2:B640))
/SUM(COUNTIF(A2:A640,{"TU","ANA36"}&"*"))



  #6   Report Post  
Harlan Grove
 
Posts: n/a
Default

Bob Phillips wrote...
or even

=AVERAGE(IF(OR(LEFT(A2:A640,2)="TU"),(LEFT(A2:A64 0,5)="ANA36")),B2:B640)

array entered.

....

Testing is good. Testing is your friend. Especially when you're still
up way too late.

Does your OR(..) term return an array? If not, it doesn't do the same
thing that Peo's formula does.

  #7   Report Post  
Harlan Grove
 
Posts: n/a
Default

Harlan Grove wrote...
....
=AVERAGE(IF(LEFT(A2:A640,2)="TU",1,LEFT(A2:A640,5 )="ANA36"),B2:B640)

....

Make that

=AVERAGE(IF(IF(LEFT(A2:A640,2)="TU",1,LEFT(A2:A640 ,5)="ANA36"),B2:B640))

  #8   Report Post  
Biff
 
Posts: n/a
Default


-----Original Message-----
Harlan Grove wrote...
....
=AVERAGE(IF(LEFT(A2:A640,2)="TU",1,LEFT(A2:A640, 5)

="ANA36"),B2:B640)
....

Make that

=AVERAGE(IF(IF(LEFT(A2:A640,2)="TU",1,LEFT(A2:A64 0,5)

="ANA36"),B2:B640))


Testing is good. Testing is your friend. Especially when
you're still up way too late.

<g

  #9   Report Post  
Bob Phillips
 
Posts: n/a
Default

Where in the OP does it suggest that an array is required, and what is the
point?

Bob

"Harlan Grove" wrote in message
oups.com...
Bob Phillips wrote...
or even

=AVERAGE(IF(OR(LEFT(A2:A640,2)="TU"),(LEFT(A2:A64 0,5)="ANA36")),B2:B640)

array entered.

...

Testing is good. Testing is your friend. Especially when you're still
up way too late.

Does your OR(..) term return an array? If not, it doesn't do the same
thing that Peo's formula does.



  #10   Report Post  
Harlan Grove
 
Posts: n/a
Default

Bob Phillips wrote...
Where in the OP does it suggest that an array is required, and what is

the
point?

....
Bob Phillips wrote...

....
=AVERAGE(IF(OR(LEFT(A2:A640,2)="TU"),(LEFT(A2:A 640,5)="ANA36")),B2:B640)

array entered.


How about a short example. A2:B7 containing

TU#### 1
ANA36@ 2
FOOBAR 3
TU 4
ANA44 5
ANA36 6

The *array* formula

=AVERAGE(IF(OR(LEFT(A2:A7,2)="TU"),(LEFT(A2:A7,5)= "ANA36")),B2:B7)

returns 3.5, which is the average of *ALL* numbers in B2:B7. Your
formula when array-entered returns the average of *ALL* numbers in
B2:B7 no matter what's in A2:A7. On the other hand, Peo's array formula

=AVERAGE(IF((LEFT(A2:A7,2)="TU")+(LEFT(A2:A7,5)="A NA36"),B2:B7))

returns 3.25. If you enter 1s in C2, C3, C5 and C7, the array formula

=AVERAGE(IF(C2:C7,B2:B7))

also returns 3.25.

Anyway, I misread your formula. I thought the B2:B640 reference was
inside the IF call. It isn't. All your IF(OR(..),..) call does is
return an array of booleans to the AVERAGE function, which then ignores
them. Is that what you intended?

Reply
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
Using The Average Function if a cell has NA carl Excel Worksheet Functions 6 May 21st 23 07:46 PM
Average Function help Cheech Excel Worksheet Functions 4 January 24th 05 03:44 PM
How do I nesting subtotal function within average function in Exc Amy Yeh Excel Worksheet Functions 4 January 19th 05 06:23 PM
Average function with If Danny Excel Worksheet Functions 2 December 3rd 04 06:27 PM
Using Average function when number is zero Deb Excel Worksheet Functions 3 November 6th 04 01:01 AM


All times are GMT +1. The time now is 11:37 AM.

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

About Us

"It's about Microsoft Excel"