A Real Challenge - Dynamic Arrays?

denzo36

Board Regular
Joined
Sep 22, 2019
Messages
228
Office Version
  1. 365
Platform
  1. Windows
Hi guys,

A real head scratcher today.

I have codes like the below in the 'Rules Codes Triggered' column.

1743765383498.png


When I pivot this, Excel treats each combination of the three codes as unique and only counts each combo once. What I want to do is count the number of times those code appear together in any order. So really for the above, codes 2044, 2045 and 2048 are appearing with each other 6 times but excel is counting each unique combo of the 3 codes only once.


Is it possible to split each cell and order it lowest to highest like the below?

1743765917825.png



I have used this to split the string at each character, removing the pipe symbol but the sorting bit I can't figure out

=MID(SUBSTITUTE(B2," | ",""),SEQUENCE(,LEN(SUBSTITUTE(B2," | ","")),1),1)


Thanks in advance
 
Is this what you are looking for?

25 04 04.xlsm
BC
1OriginalSorted
22045 | 2048 | 20442044 | 2045 | 2048
32045 | 2044 | 20482044 | 2045 | 2048
Sort
Cell Formulas
RangeFormula
C2:C3C2=TEXTJOIN(" | ",,SORT(--TEXTSPLIT(B2," | "),,,1))
 
Upvote 0
Solution
Wow Peter, 100% what I needed, that is amazing.

Thanks so much for the solution and quick response!
 
Upvote 0
You're welcome. Glad we could help. Thanks for the follow-up. :)

If all the numbers are exactly 4 digits then the "--" can be removed from my formula (as in @bobsan42's formula). I included the "--" in case some numbers were longer or shorter than 4 digits
Excel Formula:
=TEXTJOIN(" | ",,SORT(TEXTSPLIT(B2," | "),,,1))

Also, if you into saving a few characters, the formula could also be written like this. 😎
Excel Formula:
=TEXTJOIN(" | ",,SORT(TEXTSPLIT(B2,," | ")))
 
Last edited:
Upvote 0
Thanks for the mention @Peter_SSs
You're welcome. Glad we could help. Thanks for the follow-up. :)

If all the numbers are exactly 4 digits then the "--" can be removed from my formula (as in @bobsan42's formula). I included the "--" in case some numbers were longer or shorter than 4 digits
Excel Formula:
=TEXTJOIN(" | ",,SORT(TEXTSPLIT(B2," | "),,,1))
Just to clarify maybe (for future reference): -- turns (or casts?) the strings to numbers (as if using the VALUE function), then the SORT function sorts them as numbers as opposed to sorting as text.
numbers: 24 ,123 ,1221
text: 1221, 123, 24

However, in this particular case the idea is only to obtain identical strings so the order doesn't really matter.
 
Upvote 0

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