PC Review


Reply
Thread Tools Rate Thread

conditional count of single occurences

 
 
icystorm
Guest
Posts: n/a
 
      7th Nov 2010
There are two bouncing balls. Let's call them "red" and "blue". I want
to count the number of times each ball bounces higher than one inch
when dropped.

A1, B1
ball, height of bounce (inches)
red, 2.30
red, 1.20
red, 0.90
red, 0.25
blue, 2.35
blue, 1.22
blue, 0.91
blue, 0.23

For the red ball bounces that meets the bounce height criteria...

{=SUMPRODUCT($A$2:$A$9="red")*($B$2:$B$9>1)}

....returns 2.

Likewise for the blue ball.

---

Next, regardless of how many times the red ball bounces higher than
one inch, if it happens at least once, I only want to count it as a
single event, rather than multiple events. Likewise for the blue ball.

{=IF(SUMPRODUCT(($A$2:$A$9="red")*($B$2:$B$5>1))>0,1,0)}

....returns 1, as desired, for the red ball. Likewise for the blue
ball.

---

Okay, now the complicated part...

I want to place the results of the red ball and blue ball single
events in a single cell.

The result should be two in my example, because the red ball bounced
higher than one inch twice, as did the blue ball, so each instance
counts as a single event per ball.

Any recommendations?








 
Reply With Quote
 
 
 
 
joeu2004
Guest
Posts: n/a
 
      7th Nov 2010
On Nov 6, 11:01*pm, icystorm <icyst...@hotmail.com> wrote:
> I want to place the results of the red ball and blue ball single
> events in a single cell.
>
> The result should be two in my example, because the red ball bounced
> higher than one inch twice, as did the blue ball, so each instance
> counts as a single event per ball.


=(SUMPRODUCT(($A$2:$A$9="red")*($B$2:$B$5>1))>0)
+(SUMPRODUCT(($A$2:$A$9="blue")*($B$2:$B$5>1))>0)

PS: For broader participation, you might want to post future
inquiries using the MS Answers Forums at
http://social.answers.microsoft.com/...ry/officeexcel.
It's not that I like that forum. It's just that MS has ceased to
support the Usenet newsgroups. Hence, participation here is limited
to the sites that share a common newsgroup mirror, which is no longer
centralized at MS.
 
Reply With Quote
 
icystorm
Guest
Posts: n/a
 
      7th Nov 2010
On Nov 7, 12:26*am, joeu2004 <joeu2...@hotmail.com> wrote:
> On Nov 6, 11:01*pm, icystorm <icyst...@hotmail.com> wrote:
>
> > I want to place the results of the red ball and blue ball single
> > events in a single cell.

>
> > The result should be two in my example, because the red ball bounced
> > higher than one inch twice, as did the blue ball, so each instance
> > counts as a single event per ball.

>
> =(SUMPRODUCT(($A$2:$A$9="red")*($B$2:$B$5>1))>0)
> +(SUMPRODUCT(($A$2:$A$9="blue")*($B$2:$B$5>1))>0)
>
> PS: *For broader participation, you might want to post future
> inquiries using the MS Answers Forums athttp://social.answers.microsoft.com/Forums/en-US/category/officeexcel.
> It's not that I like that forum. *It's just that MS has ceased to
> support the Usenet newsgroups. *Hence, participation here is limited
> to the sites that share a common newsgroup mirror, which is no longer
> centralized at MS.


Thank you, Joeu.

I made my hypothetical case exceedingly easy. I reality, I am dealing
with thousands of different "colored balls", so it is impractical to
add them all.

Instead, what I need is a way to substitute some type of incrementing
variable for $A$2:$A$9="red" and $A$2:$A$9="blue". In fact, I could
easily assign incrementing numbers as an index. For example, all red
cases would be 1, all blue cases 2, and so forth. Could that possibly
help in creating the formula I am seeking?

My original idea to use sumproduct may not be the right approach.

Again, the single cell must return a solution based on this idea... If
any blue ball bounces higher than 1 inch at least once, return 1,
PLUS, if any red ball bounces higher than 1 inch at least once, return
1, PLUS, if any green ball bounces higher than 1 inch at least once,
return 1... and so forth. So, if all three cases were true, the final
return in the cell would be 3. But, I need to be able to do that for
thousands of different "colored balls", so summing them individually
is not practical.

Thanks also for your advice on the MS Answers Forum.

Cheers,
Joseph


 
Reply With Quote
 
Don Guillett Excel MVP
Guest
Posts: n/a
 
      7th Nov 2010
On Nov 7, 7:23*am, icystorm <icyst...@hotmail.com> wrote:
> On Nov 7, 12:26*am, joeu2004 <joeu2...@hotmail.com> wrote:
>
>
>
>
>
> > On Nov 6, 11:01*pm, icystorm <icyst...@hotmail.com> wrote:

>
> > > I want to place the results of the red ball and blue ball single
> > > events in a single cell.

>
> > > The result should be two in my example, because the red ball bounced
> > > higher than one inch twice, as did the blue ball, so each instance
> > > counts as a single event per ball.

>
> > =(SUMPRODUCT(($A$2:$A$9="red")*($B$2:$B$5>1))>0)
> > +(SUMPRODUCT(($A$2:$A$9="blue")*($B$2:$B$5>1))>0)

>
> > PS: *For broader participation, you might want to post future
> > inquiries using the MS Answers Forums athttp://social.answers.microsoft..com/Forums/en-US/category/officeexcel.
> > It's not that I like that forum. *It's just that MS has ceased to
> > support the Usenet newsgroups. *Hence, participation here is limited
> > to the sites that share a common newsgroup mirror, which is no longer
> > centralized at MS.

>
> Thank you, Joeu.
>
> I made my hypothetical case exceedingly easy. I reality, I am dealing
> with thousands of different "colored balls", so it is impractical to
> add them all.
>
> Instead, what I need is a way to substitute some type of incrementing
> variable for $A$2:$A$9="red" and $A$2:$A$9="blue". In fact, I could
> easily assign incrementing numbers as an index. For example, all red
> cases would be 1, all blue cases 2, and so forth. Could that possibly
> help in creating the formula I am seeking?
>
> My original idea to use sumproduct may not be the right approach.
>
> Again, the single cell must return a solution based on this idea... If
> any blue ball bounces higher than 1 inch at least once, return 1,
> PLUS, if any red ball bounces higher than 1 inch at least once, return
> 1, PLUS, if any green ball bounces higher than 1 inch at least once,
> return 1... and so forth. So, if all three cases were true, the final
> return in the cell would be 3. But, I need to be able to do that for
> thousands of different "colored balls", so summing them individually
> is not practical.
>
> Thanks also for your advice on the MS Answers Forum.
>
> Cheers,
> Joseph- Hide quoted text -
>
> - Show quoted text -

As answered in the answered forum

Sub CountBlocksGreterThanONE_SAS()
lr = Cells(Rows.Count, 1).End(xlUp).Row
Set mr = Range("A1:a" & lr)
mr.AdvancedFilter Action:=xlFilterInPlace, Unique:=True
For Each c In mr.SpecialCells(xlCellTypeVisible)
mf = Evaluate("=SUMPRODUCT(($A$2:$A$" & lr & "=""" _
& c & """)*($B$2:$B$" & lr & ">1))")
If mf > 0 Then ms = ms & c & " "
Next c
ActiveSheet.ShowAllData
MsgBox "Colors greater than 1 are: " & ms
End Sub
Sub CountBlocksGreterThanONEARRAY_SAS()
ma = Array("red", "green")
lr = Cells(Rows.Count, 1).End(xlUp).Row
Set mr = Range("A1:a" & lr)
For Each c In ma
' MsgBox c
mf = Evaluate("=SUMPRODUCT(($A$2:$A$" & lr & "=""" _
& c & """)*($B$2:$B$" & lr & ">1))")
'MsgBox mf
If mf > 0 Then ms = ms & c & " "
Next c
MsgBox "Colors greater than 1 are: " & ms
End Sub
 
Reply With Quote
 
The Chief Instigator
Guest
Posts: n/a
 
      9th Nov 2010
On Sat, 6 Nov 2010 23:01:57 -0700 (PDT), icystorm <(E-Mail Removed)> wrote:
> There are two bouncing balls. Let's call them "red" and "blue". I want
> to count the number of times each ball bounces higher than one inch
> when dropped.
>
> A1, B1
> ball, height of bounce (inches)
> red, 2.30
> red, 1.20
> red, 0.90
> red, 0.25
> blue, 2.35
> blue, 1.22
> blue, 0.91
> blue, 0.23
>
> For the red ball bounces that meets the bounce height criteria...
>
> {=SUMPRODUCT($A$2:$A$9="red")*($B$2:$B$9>1)}
>
> ...returns 2.
>
> Likewise for the blue ball.


I'm running Excel 2010, and that can be done as
=sumproduct(--($a$2:$a$9="red"),--($b$2:$b$9=">1")).

--
Patrick L. "The Chief Instigator" Humphrey ((E-Mail Removed)) Houston, TX
(http://www.io.com/~patrick) AA #2237
LAST GAME: Houston 4, Oklahoma City 2 (November 6)
NEXT GAME: Monday, November 8 at Abbotsford, 9:05
 
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
Make Table with Single Occurences Marguerite Hall Microsoft Access Queries 1 13th Jan 2009 05:21 PM
Re: Count # of Occurences Nick Hodge Microsoft Excel Misc 1 13th Dec 2006 11:08 PM
Count occurences =?Utf-8?B?QXZhbGFuY2hlTWlrZQ==?= Microsoft Excel Programming 4 24th Jan 2005 11:07 PM
Re: Count the occurences Michel Walsh Microsoft Access Queries 1 14th Sep 2004 09:35 AM
Count occurences of Yes or No Raymond Clarke Microsoft Access Reports 3 15th Jan 2004 07:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:32 AM.