Subgroup and list top 2

Danny54

Active Member
Joined
Jul 3, 2019
Messages
295
Office Version
  1. 365
Platform
  1. Windows
How can I go about creating a subgroup listing of the top 2

The data

Name
a
a
b
b
b
c
c
d
d
d
d


output to starting range("G15")

Top 2
D = 4
B = 3


Even the simple stuff sometimes seams difficult
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
One option:

AG
1Name
2a
3a
4b
5b
6b
7c
8c
9d
10d
11d
12d
13x
14
15Top 2
16d
17b
18a
19c
20x
21

<tbody>
</tbody>
Sheet4

Array Formulas
CellFormula
G16{=IFERROR(INDEX($A$2:$A$20,MODE(IFERROR(MATCH($A$2:$A$20,$A$2:$A$20,0)*{1,1}/(COUNTIF($G$15:$G15,$A$2:$A$20)=0),""))),"")}

<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>
 
Upvote 0
Thanks for the quick help. I did a control c on the web page taking everything between the {} and went to my excel sheet. I set the cursor on column G16. I pasted the code into the excel window at the top and did the control+shift+Enter as you suggested. My formula now has the brackets around it and returned a d in G16. which is correct. How do I get the b in G17 which would be the second highest value and the number of times found

d = 4
b = 3
 
Last edited:
Upvote 0
how do i get the second highest in the next row as well as having the number of times each one is found?

something like this

Name Found

D 4
B 3
 
Upvote 0
To get the second highest, just copy the formula in G16 to G17. (Control-C / Control-V, or just drag the cell down.) You can copy it down the column as far as you want. To get the count, enter this formula in H16:

=COUNTIF($A$2:$A$20,G16)

copy that down as far as you want.
 
Upvote 0
Again Thanks...

When I copy the formula down one or two by doing a drag, it shows the same value as the previous cell.
 
Upvote 0
Are you actually putting the formula in G16? This part of the formula:

COUNTIF($G$15:$G15,$A$2:$A$20)=0

checks the cells above to exclude any values that have already been used. If you put the formula somewhere else, say X29, you'd need to change that part to:

COUNTIF($X$28:$X28,$A$2:$A$20)=0


If it is in G16, then when you copied it, did you copy or drag? If you dragged, you selected G16, put the cursor on the tiny square on the bottom right of the cell, held down the left mouse key, and dragged down, then released?

How about the data? Are there values that look the same, but are different because of spaces?
 
Last edited:
Upvote 0
G15 has the value Top 2
G16 has the formula
=IFERROR(INDEX($A$2:$A$20,MODE(IFERROR(MATCH($A$2:$A$20,$A$2:$A$20,0)*{1,1}/(COUNTIF($G$15:$G15,$A$2:$A$20)=0),""))),"") with {} around it

this row return the letter d which is correct

Dragging down or double clicking the next formula looks like this
=IFERROR(INDEX($A$2:$A$20,MODE(IFERROR(MATCH($A$2:$A$20,$A$2:$A$20,0)*{1,1}/(COUNTIF($G$15:$G15,$A$2:$A$20)=0),""))),"") with {} around it as well

this row returns the letter d as well - should be a b.

inserting formula

=COUNTIF($A$2:$A$20,G16) into H16 gives me the count of whats found in G16.


Thanks
 
Upvote 0
G15 has the value Top 2
G16 has the formula
=IFERROR(INDEX($A$2:$A$20,MODE(IFERROR(MATCH($A$2:$A$20,$A$2:$A$20,0)*{1,1}/(COUNTIF($G$15:$G15,$A$2:$A$20)=0),""))),"") with {} around it

this row return the letter d which is correct

Dragging down or double clicking the next formula looks like this
=IFERROR(INDEX($A$2:$A$20,MODE(IFERROR(MATCH($A$2:$A$20,$A$2:$A$20,0)*{1,1}/(COUNTIF($G$15:$G15,$A$2:$A$20)=0),""))),"") with {} around it as well

this row returns the letter d as well - should be a b.

inserting formula

=COUNTIF($A$2:$A$20,G16) into H16 gives me the count of whats found in G16.


Thanks

In G16, the formula should look exactly the same as the formula in G15, EXCEPT for the value I marked in red. In G16 it should be G15, in G17 it should be G16. As you go down the column, that value should increment by 1. Notice how that value does not have a $ in front of it?
 
Upvote 0
Thanks,

this one is really strange on my end. I came in this morning with a fresh mind, redid the first column g16 and h16, applying the formulas as you suggested and got the desired results for those columns.

Now the strange stuff, I dragged using the lower right + sign down to copy the formulas to the next row. It showed the same numbers as in the previous row but looking at the formula in the window, it had incremented the row column by 1 (in the formula) as your last post showed. Being perplexed, i copied the formulas from those columns into a text pad and then pasted them back in using the shift+ctrl+enter key and they both worked. Doing this for each column and row following worked. Something funny with the drag perhaps.

What seems to be happening is the formula really isnt being copied, just the values... I wonder if its a office 365 error of some kind or a options that i've failed to set.
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,047
Members
448,940
Latest member
mdusw

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