Mode excluding previous numbers

Pestomania

Active Member
Joined
May 30, 2018
Messages
332
Office Version
  1. 365
Platform
  1. Windows
Hello!

In J2 I have Mode of Column B.
In J3 I want to have mode of column B excluding numbers equal to J2.
In J4 I want to have mode of column B excluding J2 and J3 and so forth.

I was able to get J3 to work with =Mode(if(B$2:B$107<>J2, B$2,B$107))

That works perfect. I tried adding and and function to keep it going but can't get it to work.

=Mode(if(and(B$2:B$107<>J2, B$2:B$107<>J3 , B$2,B$107))

I am using [Ctrl]+[Shift]+[Enter]
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Can you clarify exactly what you would want (& why) in J2, J3, J4, J5 & J6 for this sample data?


Excel 2016
B
1
22
33
42
53
62
73
85
96
106
116
124
134
145
15
Mode
 
Upvote 0
So J2 would get the "first mode" which in this case is 2. Then J3 would look for the "second mode" which would be 3. J4 would look at the "third mode" which is 6.

Each time it calculates the mode, I want it to exclude the previous mode.
 
Upvote 0
So J2 would get the "first mode" which in this case is 2. Then J3 would look for the "second mode" which would be 3. J4 would look at the "third mode" which is 6.

Each time it calculates the mode, I want it to exclude the previous mode.
OK, try this. It is an array formula so should be entered without the {} but confirmed with Ctrl+Shift+Enter, not just Enter. If confirmed correctly, Excel will insert the {}. The formula can then be copied down.

Note that this will not list single values. Is that an issue for you?

Excel Workbook
BJ
1
222
333
426
535
624
73
85
96
106
116
124
134
145
15
Mode
 
Last edited:
Upvote 0
Note that this will not list single values.
To allow for that, and possible blank cells in the range, try this instead. Still confirmed with Ctrl+Shift+Enter.

Excel Workbook
BJ
1
222
333
426
535
6217
734
85
96
106
116
1217
134
145
15
Mode
 
Upvote 0
To allow for that, and possible blank cells in the range, try this instead. Still confirmed with Ctrl+Shift+Enter.

Excel Workbook
BJ
1
222
333
426
535
6217
734
85
96
106
116
1217
134
145
15
Mode

I tried this program. Unfortunately it didn't include all options. For whatever it stopped calculating after a while. I cannot find the reason why it's not pulling all of them.

In the column there are 50 unique values (multiple occurrences), but it's only pulling 30.
 
Upvote 0
Another option to list single values


[Table="class: grid"][tr][td="bgcolor: #DCE6F1"][/td][td="bgcolor: #DCE6F1"]
B
[/td][td="bgcolor: #DCE6F1"]
J
[/td][/tr]
[tr][td="bgcolor: #DCE6F1"]
1
[/td][td]
Values​
[/td][td]
Result​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
2
[/td][td]
2​
[/td][td]
2​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
3
[/td][td]
3​
[/td][td]
3​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
4
[/td][td]
2​
[/td][td]
6​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
5
[/td][td]
3​
[/td][td]
5​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
6
[/td][td]
2​
[/td][td]
17​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
7
[/td][td]
3​
[/td][td]
4​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
8
[/td][td]
5​
[/td][td]
8​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
9
[/td][td]
6​
[/td][td]
11​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
10
[/td][td]
6​
[/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
11
[/td][td]
6​
[/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
12
[/td][td]
17​
[/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
13
[/td][td]
4​
[/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
14
[/td][td]
5​
[/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
15
[/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
16
[/td][td]
8​
[/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
17
[/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
18
[/td][td]
11​
[/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
19
[/td][td][/td][td][/td][/tr]
[/table]


Array formula in J2 copied down
=IFERROR(MODE(IF(B$2:B$107<>"",IF(ISNA(MATCH(B$2:B$107,J$1:J1,0)),B$2:B$107+{0,0}))),"")
confirmed with Ctrl+Shift+Enter

M.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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