COUNTIF - tracing results for further action

finnexcel

New Member
Joined
Jan 7, 2012
Messages
19
I am working from the difference between two times.

If the difference is >15 or >20 - different events occur.

I can use =COUNTIF(W:W,">0.0138888888888889") to count orders later than 20 minutes for example.

In this instance - there were 9.

But, I'd like to also return the value of column D - where the value in W is > 20mins,

I know excel knows what these rows are as the count is correct - but how can I get the Dn to return somewhere when the Wn is more than 20mins?

I hope this makes sense.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
I am working from the difference between two times.

If the difference is >15 or >20 - different events occur.

I can use =COUNTIF(W:W,">0.0138888888888889") to count orders later than 20 minutes for example.

In this instance - there were 9.

But, I'd like to also return the value of column D - where the value in W is > 20mins,

I know excel knows what these rows are as the count is correct - but how can I get the Dn to return somewhere when the Wn is more than 20mins?

I hope this makes sense.
Try this...

Book1
DWXYZAA
2Data10:17_Time0:20Data2
3Data20:25_Count5Data4
4Data30:03___Data7
5Data41:11___Data9
6Data50:19___Data13
7Data60:02____
8Data71:22____
9Data80:06____
10Data90:21____
11Data100:15____
12Data110:15____
13Data120:16____
14Data130:37____
15Data140:18____
16Data150:04____
Sheet1

Enter this formula in Z3:

=COUNTIF(W:W,">"&Z2)

Enter this array formula** in AA2:

=IF(ROWS(AA$2:AA2)>Z$3,"",INDEX(D:D,SMALL(IF(W$2:W$16>Z$2,ROW(W$2:W$16)),ROWS(AA$2:AA2))))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.

Copy down until you get blanks.
 
Upvote 0
Is there any way I can use a formula to do this?

I'm stuck - not possible to manually/visually look up the references.
 
Upvote 0
Wow!

Thanks very much - all that code hurts my brain but is amazing

I think I have it working - the results as follows:

0.01388888889 = 20minutes

Does the fact it gets the right answer - 9 mean it works?

Any ideas the reason the value is all weird like that is? (I have my intended results formatted as numbers)



0.01388888889 #VALUE!
9 #VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!



*edit* meant to copy the sheet in all cool like you did - didnt work :)
 
Last edited:
Upvote 0
Wow!

Thanks very much - all that code hurts my brain but is amazing

I think I have it working - the results as follows:

0.01388888889 = 20minutes

Does the fact it gets the right answer - 9 mean it works?
Enter the time as a time. Like this 0:20.

Here's a small sample file that demonstrates this.

LookupTimes.xls 17kb

http://cjoint.com/?BCFp4pUhaFY

The formula that extracts the data is an array formula.

Array formulas are entered differently than a regular formula. After you type in a regular formula you hit the ENTER key. With an array formula you *must* use a combination of keys. Those keys are the CTRL key, the SHIFT key and the ENTER key. That is, hold down both the CTRL key and the SHIFT key then hit the ENTER key.

When done properly Excel will enclose the formula in squiggly brackets { }. You can't just type these brackets in, you *must* use the key combo to produce them. Also, anytime you edit an array formula it *must* be re-entered as an array using the key combo.
 
Upvote 0
Thanks Biff! - I've changed Z2 to a time - and it still worked - and counted 9

I also double checked I was entering the array right - I have the right brackets 100%

Is it possible a format error - This #VALUE stuff used to happen a lot when I was messing up VLOOKUPS


Tried to trace error:

"encountered tracer errors or circular reference"

My W column does contain instances of #VALUE - Could that be messing it up?
 
Upvote 0
Thanks Biff! - I've changed Z2 to a time - and it still worked - and counted 9

I also double checked I was entering the array right - I have the right brackets 100%

Is it possible a format error - This #VALUE stuff used to happen a lot when I was messing up VLOOKUPS


Tried to trace error:

"encountered tracer errors or circular reference"

My W column does contain instances of #VALUE - Could that be messing it up?
Yes, that's probably what's giving you the errors.

Here's the updated version:

Book1
DWXYZAA
2Data10:17_Time0:20Data2
3Data20:25_Count5Data4
4Data30:03___Data7
5Data41:11___Data9
6Data50:19___Data13
7Data6#VALUE!____
8Data71:22____
9Data80:06____
10Data90:21____
11Data100:15____
12Data11#VALUE!____
13Data120:16____
14Data130:37____
15Data140:18____
16Data150:04____
Sheet1

This array formula** entered in AA2:

=IF(ROWS(AA$2:AA2)>Z$3,"",INDEX(D:D,SMALL(IF(ISNUMBER(W$2:W$16),IF(W$2:W$16>Z$2,ROW(W$2:W$16))),ROWS(AA$2:AA2))))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.

Copy down until you get blanks.
 
Upvote 0
Thanks again.

Something changed in that the #VALUE error is now a #NUM error

Still counts correctly and results in 9 -my D column references are definitely numbers.

Any ideas? ( I did read around and try and correct this myself - haven't got anywhere - the references are 6 digit - so not too big, or negative)

Any ideas?
 
Upvote 0
Thanks again.

Something changed in that the #VALUE error is now a #NUM error

Still counts correctly and results in 9 -my D column references are definitely numbers.

Any ideas? ( I did read around and try and correct this myself - haven't got anywhere - the references are 6 digit - so not too big, or negative)

Any ideas?
You'll get the #NUM! error a couple of ways...

If you don't array enter the extraction formulas.

If you use entire columns as range references in the array formulas and you're using Excel version 2003 or earlier.

Here's the updated sample file that accounts for the #VALUE! errors.

LookupTimesV2.xls 18kb

http://cjoint.com/?BCFxthGD1mQ
 
Upvote 0

Forum statistics

Threads
1,215,563
Messages
6,125,568
Members
449,237
Latest member
Chase S

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top