all possible combination formula for numbers

awanone

New Member
Joined
Jul 26, 2020
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
Hi All,
I would like to find out a formula for the following situation, i have the following 5 integers lets say A, B, C, D, E (they can be numbers in between 0 to 4 & one number can repeat in the sequence like 01202 here 2 and 0 is repeating ) , i would like to see all the possible combinations for example ( as example stated 01202 would want to see all combinations possible such as 00122, 22001,12020 so on ... ). so is there any formula in excel where I can give the numbers and it can provide me with all possible combinations, thanks for the help
 
or like this
#1#2#3#4#5Number
0012200122
00212
00221
01022
01202
01220
02012
02021
02102
02120
02201
02210
10022
10202
10220
12002
12020
12200
20012
20021
20102
20120
20201
20210
21002
21020
21200
22001
22010
22100

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Transpose = Table.Transpose(Source),
    ExpandFirst = Table.ExpandListColumn(Table.AddColumn(Transpose, "Custom", each {0..4}), "Custom"),
    ExpandSecond = Table.ExpandListColumn(Table.AddColumn(ExpandFirst, "Custom.1", each {0..4}), "Custom.1"),
    ExpandThird = Table.ExpandListColumn(Table.AddColumn(ExpandSecond, "Custom.2", each {0..4}), "Custom.2"),
    ExpandFourth = Table.ExpandListColumn(Table.AddColumn(ExpandThird, "Custom.3", each {0..4}), "Custom.3"),
    Type = Table.TransformColumnTypes(ExpandFourth,{{"Column1", type text}, {"Custom", type text}, {"Custom.1", type text}, {"Custom.2", type text}, {"Custom.3", type text}}),
    Join = Table.AddColumn(Type, "Number", each [Column1]&[Custom]&[Custom.1]&[Custom.2]&[Custom.3]),
    SortAsc = Table.Sort(Table.Distinct(Table.SelectColumns(Join,{"Number"})),{{"Number", Order.Ascending}}),
    Filter0 = Table.SelectRows(Table.AddColumn(SortAsc, "Custom", each List.Count(Text.Split([Number],"0"))-1), each ([Custom] = 0 or [Custom] = 1 or [Custom] = 2)),
    Filter1 = Table.SelectRows(Table.AddColumn(Filter0, "Custom.1", each List.Count(Text.Split([Number],"1"))-1), each ([Custom.1] = 0 or [Custom.1] = 1)),
    Filter2 = Table.SelectRows(Table.AddColumn(Filter1, "Custom.2", each List.Count(Text.Split([Number],"2"))-1), each ([Custom.2] = 0 or [Custom.2] = 1 or [Custom.2] = 2)),
    Filter3 = Table.SelectRows(Table.AddColumn(Filter2, "Custom.3", each List.Count(Text.Split([Number],"3"))-1), each ([Custom.3] = 0 or [Custom.3] = 0)),
    Filter4 = Table.SelectRows(Table.AddColumn(Filter3, "Custom.4", each List.Count(Text.Split([Number],"4"))-1), each ([Custom.4] = 0 or [Custom.4] = 0)),
    TSC = Table.SelectColumns(Filter4,{"Number"})
in
    TSC
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
here is case with defined repeats

Number0Number1Number2Number3Number4WarningNumbersNumber
Repeat212005000122
100212
200221
301022
401202
01220
02012
02021
02102
02120
02201
02210
10022
10202
10220
12002
12020
12200
20012
20021
20102
20120
20201
20210
21002
21020
21200
22001
22010
22100
30
 
Upvote 0
Cross posted on Reddit

While we do allow Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
The solution provided in reddit is not dynamic in nature and seems to ignore the fact that numbers can change.
Can someone help with a formula based answer
 
Upvote 0

Forum statistics

Threads
1,216,116
Messages
6,128,930
Members
449,479
Latest member
nana abanyin

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