PC Review


Reply
Thread Tools Rate Thread

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

 
 
Liv
Guest
Posts: n/a
 
      19th Nov 2009
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?
 
Reply With Quote
 
 
 
 
Pete_UK
Guest
Posts: n/a
 
      19th Nov 2009
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$7<5),$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$7<5))

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 <L...@discussions.microsoft.com> 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?


 
Reply With Quote
 
Liv
Guest
Posts: n/a
 
      19th Nov 2009
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$7<5),$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$7<5))
>
> 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 <L...@discussions.microsoft.com> 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?

>
> .
>

 
Reply With Quote
 
David Biddulph
Guest
Posts: n/a
 
      19th Nov 2009
=SUMPRODUCT(($A$2:$A$7=B$10)*($B$2:$B$7>=5)*($B$2:$B$7<7),$B$2:$B$7)
--
David Biddulph

"Liv" <(E-Mail Removed)> wrote in message
news:60C3763D-4FFE-49EE-854D-(E-Mail Removed)...
> 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$7<5),$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$7<5))
>>
>> 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 <L...@discussions.microsoft.com> 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?

>>
>> .
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count number of times a text occurs Lee Microsoft Excel New Users 3 11th Oct 2008 10:03 PM
Need to Count the number of times a value occurs within a dt range Gina Microsoft Excel Worksheet Functions 9 4th Jul 2008 10:19 PM
Count the number of times a name occurs in a column Gary Microsoft Excel Worksheet Functions 2 28th Dec 2006 12:07 AM
How do I count the times a number occurs in a given criteria? =?Utf-8?B?d19hbGxlcg==?= Microsoft Excel Misc 2 3rd Feb 2005 09:06 AM
Macro to Count how many times a number occurs on a day SirMetro Microsoft Excel Programming 8 2nd Feb 2005 05:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:31 PM.