Nth occurrence

Bugas

New Member
Joined
Sep 17, 2012
Messages
44
Office Version
  1. 2007
Platform
  1. Windows
Hi!

My table looks this:


xyzaaab
100ClientJan-12Fev-12Mar-12Apr-12
101aaa1131
102bbb3212
103ccc1212
104ddd4434
105eee5454
106fff5656
107ggg5676
108hhh5888

<tbody>
</tbody>


For Jan-12 I would get this information:

Jan-12
1aaa
1ccc
3bbb
4ddd
5eee
5fff
5ggg
5hhh

<tbody>
</tbody>


I'm trying to get the second, third, ... occurrence. It's not starting on A1. When I use vlookup, I only get the first occurance, ignoring the 2nd or the 3rd. I

I want to use excel formula.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Hi and welcome to the Board.
Why don't you simply sort the table, Ascending, by Jan-12...:confused:
 
Upvote 0
Thanks for your support, but sorting is not an option.


100</SPAN>Client</SPAN>Jan-12</SPAN>01-Feb</SPAN>Mar-12</SPAN>Apr-12</SPAN> Rank</SPAN>Return</SPAN>Mar-12</SPAN>
101</SPAN>aaa</SPAN>1</SPAN>1</SPAN>3</SPAN>1</SPAN> 3</SPAN>1</SPAN>bbb</SPAN>
102</SPAN>bbb</SPAN>3</SPAN>2</SPAN>1</SPAN>2</SPAN> 1</SPAN>1</SPAN>ccc</SPAN>
103</SPAN>ccc</SPAN>1</SPAN>2</SPAN>1</SPAN>2</SPAN> 2</SPAN>3</SPAN>aaa</SPAN>
104</SPAN>ddd</SPAN>4</SPAN>4</SPAN>3</SPAN>4</SPAN> 4</SPAN>3</SPAN>ddd</SPAN>
105</SPAN>eee</SPAN>5</SPAN>4</SPAN>5</SPAN>4</SPAN> 5</SPAN>5</SPAN>eee</SPAN>
106</SPAN>fff</SPAN>5</SPAN>6</SPAN>5</SPAN>6</SPAN> 6</SPAN>5</SPAN>fff</SPAN>
107</SPAN>ggg</SPAN>5</SPAN>6</SPAN>7</SPAN>6</SPAN> 7</SPAN>7</SPAN>ggg</SPAN>
108</SPAN>hhh</SPAN>5</SPAN>8</SPAN>8</SPAN>8</SPAN> 8</SPAN>8</SPAN>hhh</SPAN>

<TBODY>
</TBODY><COLGROUP><COL><COL><COL><COL><COL span=2><COL span=2><COL><COL span=2></COLGROUP>



With an helper column (I)
I2 copy down
=RANK(HLOOKUP($K$1,$C$1:$F$9,ROWS($A$1:A2),0),INDEX($C$2:$F$9,,MATCH(K$1,$C$1:$F$1,0)),-1)+COUNTIF(INDEX($C$2:F2,,MATCH(K$1,$C$1:$F$1,0)),HLOOKUP($K$1,$C$1:$F$9,ROWS($A$1:A2),0))-1
J2 copy down
=INDEX($C$2:$F$9,MATCH(ROW()-1,$I$2:$I$9,0),MATCH(K$1,$C$1:$F$1,0))
K2 copy down:
=INDEX($B$2:$B$9,MATCH(ROW()-1,$I$2:$I$9,0))
you can change the date in K1 to one from the first row
 
Upvote 0
Hi All,

if in column B (January 12) there are numbers, in order to get an ascending list in (example) G2 you could try:

Code:
=SMALL($B$2:$B$100,ROWS($A$1:A1))

Then in H2 in order to get first, second... occurence (A2:A100=clients),

Code:
=INDEX($A$2:$A$100,SMALL(IF($B$2:$B$100=G2,ROW($A$2:$A$100)-1),COUNTIF(G$2:G2,G2)))

This formula must be confirmed with control+shift+enter

Hope that helps
 
Upvote 0
Thank you all for your help. It works fine when I put them starting on A1. But my data doesn't start on A1. Client aaa for Jan-2012 is on Y101. If i move that cells it gives me error.

I put my data on Column Y, Z, AA, AB and rows 100, 101, 102, 130, 104, 105, 106, 107, 108.
 
Upvote 0
Thank you all for your help. It works fine when I put them starting on A1. But my data doesn't start on A1. Client aaa for Jan-2012 is on Y101. If i move that cells it gives me error.

I put my data on Column Y, Z, AA, AB and rows 100, 101, 102, 130, 104, 105, 106, 107, 108.


Sheet2 column A start in A2:
=SMALL(INDEX(Sheet1!$Z$101:$AC$108,,MATCH(B$1,Sheet1!$Z$100:$AC$100,0)),ROWS(Sheet1!$A$1:A1))
in B2 confirm COntrol+Shift+enter
=INDEX(Sheet1!$Y$101:$Y$108,SMALL(IF(INDEX(Sheet1!$Z$101:$AC$108,,MATCH(B$1,Sheet1!$Z$100:$AC$100,0))=$A2,ROW($A$2:$A$9)-ROW($A$2)+1),COUNTIF($A$2:A2,A2)))

B1 is your Date
01/01/12
 
Upvote 0
Thank you for your support, but I can't make it with that formula. It gives me error #N/A

Sheet2 column A start in A2:
=SMALL(INDEX(Sheet1!$Z$101:$AC$108,,MATCH(B$1,Sheet1!$Z$100:$AC$100,0)),ROWS(Sheet1!$A$1:A1))
in B2 confirm COntrol+Shift+enter
=INDEX(Sheet1!$Y$101:$Y$108,SMALL(IF(INDEX(Sheet1!$Z$101:$AC$108,,MATCH(B$1,Sheet1!$Z$100:$AC$100,0))=$A2,ROW($A$2:$A$9)-ROW($A$2)+1),COUNTIF($A$2:A2,A2)))

B1 is your Date
01/01/12
 
Upvote 0
Thank you for your support, but I can't make it with that formula. It gives me error #N/A

Excel 2010
XYZAAABACADAE
93
94
95
96
97
98
99
100Client1-Jan1-FebMar-12Apr-12
101aaa1131
102bbb3212
103ccc1212
104ddd4434
105eee5454
106fff5656
107ggg5676
108hhh5888
109
110
111
112
113
114
115

<tbody>
</tbody>
Sheet1



Excel 2010
ABC
11-Jan
21aaa
31ccc
43bbb
54ddd
65eee
75fff
85ggg
95hhh
10

<tbody>
</tbody>
Return

Worksheet Formulas
CellFormula
A2=SMALL(INDEX(Sheet1!$Z$101:$AC$108,,MATCH(B$1,Sheet1!$Z$100:$AC$100,0)),ROWS(A$2:A2))

<tbody>
</tbody>

<tbody>
</tbody>

Array Formulas
CellFormula
B2{=INDEX(Sheet1!$Y$101:$Y$108,SMALL(IF(INDEX(Sheet1!$Z$101:$AC$108,,MATCH(B$1,Sheet1!$Z$100:$AC$100,0))=$A2,ROW($A$2:$A$9)-ROW($A$2)+1),COUNTIF($A$2:A2,A2)))}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself


<tbody>
</tbody>



Are the values different foreach column or they can be diffrent lenght?
If yes we need some adjustemnt to the formulas.

Probably you did not correctly confirm the array formulae from Robert.
Thanks Canapone.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,527
Messages
6,160,342
Members
451,638
Latest member
MyFlower

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