Determining number of possible combinations of a set of numbers

gravanoc

Active Member
Joined
Oct 20, 2015
Messages
346
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I have a formula that generates all the unique possible combinations from a set of numbers in two columns where the first column's number is always the first digit in the combination.
1633472487279.png

In the above example, there are 16 combinations fitting that description that are then filtered down to 9 after taking the unique combinations.. I would like to know if there is a formula that I can use that would generate that number, 9, for the possible combinations. Variations of using the combination functions (COMBIN, COMBINA) don't seem to do the trick. Thanks.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
In this case, the number of combinations is just the number of elements in column 1 times the number of elements in column 2. The number of unique values would be tougher to find.

Edit: the number of unique combinations would be the number of unique elements in column1 times the number of unique elements in column2.
 
Upvote 0
delme1.xlsm
ABCDE
1Col 1Col 2Number Unique Combinationsif version doesn't include UNIQUE function
20099
311
431
519
61
Sheet4
Cell Formulas
RangeFormula
D2D2=ROWS(UNIQUE(A2:A6))*ROWS(UNIQUE(B2:B5))
E2E2=SUM(1/COUNTIF(A2:A6,A2:A6))*SUM(1/COUNTIF(B2:B5,B2:B5))
 
Upvote 0
Solution
delme1.xlsm
ABCDE
1Col 1Col 2Number Unique Combinationsif version doesn't include UNIQUE function
20099
311
431
519
61
Sheet4
Cell Formulas
RangeFormula
D2D2=ROWS(UNIQUE(A2:A6))*ROWS(UNIQUE(B2:B5))
E2E2=SUM(1/COUNTIF(A2:A6,A2:A6))*SUM(1/COUNTIF(B2:B5,B2:B5))

Awesome. How did you figure it out, if you don't mind sharing?
 
Upvote 0
As Eric wrote above, the number of unique combinations (order dependent - meaning e.g., 12 and 21 each count) is the product of the number of unique items in the first column and the number of unique items in the second column. In 365 the UNIQUE function returns the list of unique items from an array, the rows function returns the number of rows in an array which is the number of items for an nX1 array -so ROWS(UNIQUE(array1))*ROWS(UNIQUE(array2)) for vertical one column arrays returns the intended result. For versions without the UNIQUE function the SUM(1/COUNTIF construction does the same (if there is only one of an item it contributes 1 to the sum, if 2 each contribute 1/2, if 3 each 1/3 ... so always sums to the number of unique items).
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,195
Members
449,072
Latest member
DW Draft

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