Add an extra choice to a dynamic array formula

Tarver

Board Regular
Joined
Nov 15, 2012
Messages
109
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I've got a formula that gives me n unique items from a sorted pivot table (starting at $A$6.). I enter the n number of entries I want to see (in cell $C$2), and the list updates:

=UNIQUE($A$6:OFFSET($A$6,$C$2,0))

However, I'd also like to force an additional entry at the bottom of this list, "All Others." So, if I ask for 5 items, I want to see a sixth at the bottom.

Is there a way to modify the existing formula to force that "All Others" entry at bottom?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Your formula does not work quite as you described. If any items in A6 to A6+n-1 repeat then the unique function will return fewer than n items. In the example below the formula returns 4 (not 5) unique items because B is repeated once in the first five items.

That problem aside you can redimension and add a last row like this:

Book1
ABCD
1
25
3
4
5
6AA
7BB
8CC
9BD
10DAll Others
11A
12C
13E
14D
15F
16B
17A
18D
19F
20
Sheet2
Cell Formulas
RangeFormula
C6:C10C6=LET(a, UNIQUE($A$6:OFFSET($A$6,$C$2,0)), s, SEQUENCE(ROWS(a)+1), IF(s<ROWS(s),INDEX(a,s), "All Others"))
Dynamic array formulas.
 
Upvote 0
Solution
Never would've come up with that formula, but it works perfectly. Thank you.

You are correct that my formula won't catch a repeat, but since it's applied to a pivot where the values are sorted, that won't be an issue.

Thanks again for your help!
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,466
Members
449,086
Latest member
kwindels

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