Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9
Default Count values in column only if value of another column is true

OK,

I have a spreadsheet with a large amount of data but want to create a
formula based on just two of the columns both containing text values as
follows:

BOOK LONDON
BOOK NEWYORK
BOOK LONDON
BOOK LONDON
BOOK LONDON
BOOK OXFORD
MAGAZINE LONDON
MAGAZINE LONDON
MAGAZINE OXFORD
MAGAZINE OXFORD
MAGAZINE OXFORD

and so on....

I need a formula which will count the number of "BOOK" in "LONDON" or
MAGAZINE in OXFORD.

Hence I need something that basically has the logic:

If B1 = LONDON and A1 = BOOK, Count it.....and then perform the same again
on each row.

=COUNTIF(A1:A100,"BOOK") will count the number of times BOOK appears in
column A but how do I take the next step and only count it if the
corresponding value in column B is LONDON etc?

Thanks in advance


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Count values in column only if value of another column is true

Try this

=SUMPRODUCT((A1:A10="Book")*(B1:B10="London"))

In practice i'd use cell references

=SUMPRODUCT((A1:A10=C1)*(B1:B10=D1))

Mike

"MikeB" wrote:

OK,

I have a spreadsheet with a large amount of data but want to create a
formula based on just two of the columns both containing text values as
follows:

BOOK LONDON
BOOK NEWYORK
BOOK LONDON
BOOK LONDON
BOOK LONDON
BOOK OXFORD
MAGAZINE LONDON
MAGAZINE LONDON
MAGAZINE OXFORD
MAGAZINE OXFORD
MAGAZINE OXFORD

and so on....

I need a formula which will count the number of "BOOK" in "LONDON" or
MAGAZINE in OXFORD.

Hence I need something that basically has the logic:

If B1 = LONDON and A1 = BOOK, Count it.....and then perform the same again
on each row.

=COUNTIF(A1:A100,"BOOK") will count the number of times BOOK appears in
column A but how do I take the next step and only count it if the
corresponding value in column B is LONDON etc?

Thanks in advance


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default Count values in column only if value of another column is true

Try
=SUMPRODUCT(--(A2:A10="Book"),--(B2:B10="London"))

If this post helps click Yes
---------------
Jacob Skaria


"MikeB" wrote:

OK,

I have a spreadsheet with a large amount of data but want to create a
formula based on just two of the columns both containing text values as
follows:

BOOK LONDON
BOOK NEWYORK
BOOK LONDON
BOOK LONDON
BOOK LONDON
BOOK OXFORD
MAGAZINE LONDON
MAGAZINE LONDON
MAGAZINE OXFORD
MAGAZINE OXFORD
MAGAZINE OXFORD

and so on....

I need a formula which will count the number of "BOOK" in "LONDON" or
MAGAZINE in OXFORD.

Hence I need something that basically has the logic:

If B1 = LONDON and A1 = BOOK, Count it.....and then perform the same again
on each row.

=COUNTIF(A1:A100,"BOOK") will count the number of times BOOK appears in
column A but how do I take the next step and only count it if the
corresponding value in column B is LONDON etc?

Thanks in advance


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9
Default Count values in column only if value of another column is true

I think I might have fixed it myself with:

=SUMPRODUCT((A2:A1000="BOOK")*(B2:B1000="LONDON"))

"MikeB" wrote:

OK,

I have a spreadsheet with a large amount of data but want to create a
formula based on just two of the columns both containing text values as
follows:

BOOK LONDON
BOOK NEWYORK
BOOK LONDON
BOOK LONDON
BOOK LONDON
BOOK OXFORD
MAGAZINE LONDON
MAGAZINE LONDON
MAGAZINE OXFORD
MAGAZINE OXFORD
MAGAZINE OXFORD

and so on....

I need a formula which will count the number of "BOOK" in "LONDON" or
MAGAZINE in OXFORD.

Hence I need something that basically has the logic:

If B1 = LONDON and A1 = BOOK, Count it.....and then perform the same again
on each row.

=COUNTIF(A1:A100,"BOOK") will count the number of times BOOK appears in
column A but how do I take the next step and only count it if the
corresponding value in column B is LONDON etc?

Thanks in advance


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,836
Default Count values in column only if value of another column is true

=SUMPRODUCT(($A$1:$A$14="Book")*($B$1:$B$14="Londo n"))+SUMPRODUCT(($A$1:$A$14="Magazine")*($B$1:$B$1 4="Oxford"))

HTH,
Ryan--

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"MikeB" wrote:

I think I might have fixed it myself with:

=SUMPRODUCT((A2:A1000="BOOK")*(B2:B1000="LONDON"))

"MikeB" wrote:

OK,

I have a spreadsheet with a large amount of data but want to create a
formula based on just two of the columns both containing text values as
follows:

BOOK LONDON
BOOK NEWYORK
BOOK LONDON
BOOK LONDON
BOOK LONDON
BOOK OXFORD
MAGAZINE LONDON
MAGAZINE LONDON
MAGAZINE OXFORD
MAGAZINE OXFORD
MAGAZINE OXFORD

and so on....

I need a formula which will count the number of "BOOK" in "LONDON" or
MAGAZINE in OXFORD.

Hence I need something that basically has the logic:

If B1 = LONDON and A1 = BOOK, Count it.....and then perform the same again
on each row.

=COUNTIF(A1:A100,"BOOK") will count the number of times BOOK appears in
column A but how do I take the next step and only count it if the
corresponding value in column B is LONDON etc?

Thanks in advance




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
excel-count a value in 1 column if a value in a 2nd is true Jim C. Excel Worksheet Functions 5 August 28th 09 10:47 PM
Count Unique Values in 1 Column based on Date Range in another Column Brian Excel Worksheet Functions 14 May 17th 09 02:58 PM
Count cells w/values in column if the data in column a matches cri mdcgpw Excel Worksheet Functions 4 January 12th 09 11:55 PM
Count entries in one column based on values in another column Kurt Excel Worksheet Functions 7 January 10th 07 09:29 PM
how 2sum values in column C, IF 'X' & 'Y' in colums A & B =TRUE JW in Dubai Excel Worksheet Functions 2 July 1st 06 06:34 AM


All times are GMT +1. The time now is 12:28 PM.

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"