Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default applying function depending on condition in other cell

Hi experts,

If I have data like this

A B
-------------
x 2
x 5
y 6
x 1
y 2
x 3

How do I include the values of column B in a function, only if the
values have a corresponding x in the A column. For example if I would
like to calculate the AVERAGE only of the values in B which has the
value X in A.

Jonas

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default applying function depending on condition in other cell

Try:

Assumes data is in range a1 to b10

=Sumif(a1:a10,"x",b1:b10)/countif(a1:a10,"x")

HTH

" wrote:

Hi experts,

If I have data like this

A B
-------------
x 2
x 5
y 6
x 1
y 2
x 3

How do I include the values of column B in a function, only if the
values have a corresponding x in the A column. For example if I would
like to calculate the AVERAGE only of the values in B which has the
value X in A.

Jonas


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default applying function depending on condition in other cell

Great! Thanks a lot, I've always thought there was a smarter way to do
this than using only the "if"-statement and several new columns of
space, but I never new about "sumif" and "countif".
This is of course very appropriate for simple things as summing or
averaging, but is there also a more general way to do similar things
for an arbitrary function?

Jonas, very gratetful for the quick answer!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default applying function depending on condition in other cell

or

=AVERAGE(IF(A1:A10="x",B1:B10))

which is an array formula, so is committed with Ctrl-Shift-Enter

--

HTH

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


"Toppers" wrote in message
...
Try:

Assumes data is in range a1 to b10

=Sumif(a1:a10,"x",b1:b10)/countif(a1:a10,"x")

HTH

" wrote:

Hi experts,

If I have data like this

A B
-------------
x 2
x 5
y 6
x 1
y 2
x 3

How do I include the values of column B in a function, only if the
values have a corresponding x in the A column. For example if I would
like to calculate the AVERAGE only of the values in B which has the
value X in A.

Jonas




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default applying function depending on condition in other cell

My solution shows you that.

--

HTH

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


wrote in message
ups.com...
Great! Thanks a lot, I've always thought there was a smarter way to do
this than using only the "if"-statement and several new columns of
space, but I never new about "sumif" and "countif".
This is of course very appropriate for simple things as summing or
averaging, but is there also a more general way to do similar things
for an arbitrary function?

Jonas, very gratetful for the quick answer!





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default applying function depending on condition in other cell

Thanks!
Today is a very nice day, never heard about array formulas before.
Seems extremely useful.

Jonas

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
Applying Max Conditonal Formatting to an entire row when condition SunshineinFt.Myers[_2_] Excel Worksheet Functions 2 February 24th 09 05:56 AM
Condition depending on tab colour excel Excel Worksheet Functions 3 July 15th 07 10:23 PM
Displaying a number with different decimals depending on a condition JGarces Excel Worksheet Functions 1 August 16th 06 05:37 PM
changing a cell value depending on an If Function/Lookup Chris Excel Worksheet Functions 2 November 9th 04 07:41 AM
deleting the rows depending on the result of a condition involving two columns. pkseelam Excel Programming 2 August 26th 03 02:52 PM


All times are GMT +1. The time now is 06:44 PM.

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"