A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

how to count the number of times text occurs based on condition



 
 
Thread Tools Display Modes
  #1  
Old November 19th, 2009, 12:10 AM posted to microsoft.public.excel.misc
Liv[_2_]
external usenet poster
 
Posts: 21
Default how to count the number of times text occurs based on condition

scenario:

i would like to return two numbers, the count of times each fruit occurs
when 5 and =5, and the sum of the value when each fruit is 5 and =5

FRUIT $$$
apple 1
orange 2
pear 1
pear 8
pear 5
apple 6

should return

apple orange pear
sum 5 1 2 1
sum =5 6 0 13

apple orange pear
count 5 1 1 1
count =5 1 0 2

how do i go about this?
  #2  
Old November 19th, 2009, 01:06 AM posted to microsoft.public.excel.misc
Pete_UK
external usenet poster
 
Posts: 8,780
Default how to count the number of times text occurs based on condition

Assume your data is in A2:B7, with headings in row 1, and that your
first table has headings starting in B10 and the second table has
headings starting in B14. Put this in B11:

=SUMPRODUCT(($A$2:$A$7=B$10)*($B$2:$B$75),$B$2:$B $7)

and this in B12:

=SUMPRODUCT(($A$2:$A$7=B$10)*($B$2:$B$7=5),$B$2:$ B$7)

then copy across to C1112.

Similarly, put this in B15:

=SUMPRODUCT(($A$2:$A$7=B$14)*($B$2:$B$75))

and this in B16:

=SUMPRODUCT(($A$2:$A$7=B$14)*($B$2:$B$7=5))

and copy both of these across.

Hope this helps.

Pete

On Nov 19, 12:10*am, Liv wrote:
scenario:

i would like to return two numbers, the count of times each fruit occurs
when 5 and =5, and the sum of the value when each fruit is 5 and =5

FRUIT * $$$
apple * * 1
orange * 2
pear * * *1
pear * * *8
pear * * *5
apple * * 6

should return

* * * * * * * *apple * *orange * pear
sum * 5 * * 1 * * * * * 2 * * * * *1
sum =5 * * 6 * * * * * 0 * * * * *13

* * * * * * * * apple * *orange * pear
count * 5 * *1 * * * * * *1 * * * * 1
count =5 * *1 * * * * * *0 * * * * 2

how do i go about this?


  #3  
Old November 19th, 2009, 04:10 PM posted to microsoft.public.excel.misc
Liv[_2_]
external usenet poster
 
Posts: 21
Default how to count the number of times text occurs based on conditio

Thank you Pete! Is there a way to fit two conditions into the equation?
For instance if I were asked to return whatever is =5 AND 7

"Pete_UK" wrote:

Assume your data is in A2:B7, with headings in row 1, and that your
first table has headings starting in B10 and the second table has
headings starting in B14. Put this in B11:

=SUMPRODUCT(($A$2:$A$7=B$10)*($B$2:$B$75),$B$2:$B $7)

and this in B12:

=SUMPRODUCT(($A$2:$A$7=B$10)*($B$2:$B$7=5),$B$2:$ B$7)

then copy across to C1112.

Similarly, put this in B15:

=SUMPRODUCT(($A$2:$A$7=B$14)*($B$2:$B$75))

and this in B16:

=SUMPRODUCT(($A$2:$A$7=B$14)*($B$2:$B$7=5))

and copy both of these across.

Hope this helps.

Pete

On Nov 19, 12:10 am, Liv wrote:
scenario:

i would like to return two numbers, the count of times each fruit occurs
when 5 and =5, and the sum of the value when each fruit is 5 and =5

FRUIT $$$
apple 1
orange 2
pear 1
pear 8
pear 5
apple 6

should return

apple orange pear
sum 5 1 2 1
sum =5 6 0 13

apple orange pear
count 5 1 1 1
count =5 1 0 2

how do i go about this?


.

  #4  
Old November 19th, 2009, 04:38 PM posted to microsoft.public.excel.misc
David Biddulph
external usenet poster
 
Posts: 8,714
Default how to count the number of times text occurs based on conditio

=SUMPRODUCT(($A$2:$A$7=B$10)*($B$2:$B$7=5)*($B$2: $B$77),$B$2:$B$7)
--
David Biddulph

"Liv" wrote in message
...
Thank you Pete! Is there a way to fit two conditions into the equation?
For instance if I were asked to return whatever is =5 AND 7

"Pete_UK" wrote:

Assume your data is in A2:B7, with headings in row 1, and that your
first table has headings starting in B10 and the second table has
headings starting in B14. Put this in B11:

=SUMPRODUCT(($A$2:$A$7=B$10)*($B$2:$B$75),$B$2:$B $7)

and this in B12:

=SUMPRODUCT(($A$2:$A$7=B$10)*($B$2:$B$7=5),$B$2:$ B$7)

then copy across to C1112.

Similarly, put this in B15:

=SUMPRODUCT(($A$2:$A$7=B$14)*($B$2:$B$75))

and this in B16:

=SUMPRODUCT(($A$2:$A$7=B$14)*($B$2:$B$7=5))

and copy both of these across.

Hope this helps.

Pete

On Nov 19, 12:10 am, Liv wrote:
scenario:

i would like to return two numbers, the count of times each fruit
occurs
when 5 and =5, and the sum of the value when each fruit is 5 and =5

FRUIT $$$
apple 1
orange 2
pear 1
pear 8
pear 5
apple 6

should return

apple orange pear
sum 5 1 2 1
sum =5 6 0 13

apple orange pear
count 5 1 1 1
count =5 1 0 2

how do i go about this?


.



 




Thread Tools
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 On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:32 PM.


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