Excel Pattern Matching?

SrSeagull

New Member
Joined
Feb 6, 2017
Messages
1
Is there a way to match patterns of characteristics of data? Assume I have 10,000 rows of data and each is made up for 5 columns. The first column is a unique customer number and the remaining four columns each have either a 1 or 0. There are 15 unique patterns of 1 or 0 in the data set (e.g. 1,1,1,1 or 1,1,0,1, or 1,0,1,1 or 0,1,0,0 etc...). For each row of data I am trying to match its pattern against the 15 possible combinations and determine which combination it is? Any suggestions?
DATAPossibleOutcomes
Year 1Year 2Year 3Year 4Formula?Year 1Year 2Year 3Year 4
Customer11111A
A1111
Customer21011EB1110
Customer31111C1101
Customer41111D1100
Customer51011E1011
Customer61010F1010
Customer71001G1001
Customer81010H1000
Customer91010I0111
Customer101000J0110
Customer110111K0101
Customer120110L0100
Customer130101M0011
Customer140101N0010
Customer150011O0001
Customer160010
Customer170001

<tbody>
</tbody>
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Welcome to the forum.

There are ways to use INDEX/MATCH on multiple columns, but seeing as how your patterns are just counting in binary, this should be more efficient:

G3: =CHAR(80-(C4*8+D4*4+E4*2+F4))


This does assume you want the actual letters A, B, etc. If you want to search down column I for the actual name, you could use:

=INDEX($I$3:$I$17,16-(C4*8+D4*4+E4*2+F4))
 
Last edited:
Upvote 0
love your index solution Eric W .. so elegant!

just one point you may like to consider SrSeagull . you sated that your current data has 15 unique patterns ..


It would be a good idea to also cater for the 16th possibility ie all zeroes .. While none of your current customers have all zeroes this colud happen in future and if it did then the current formula will return N/A
(and even if it never happens no harm will be done by considering the possibility )
this would makes Eric W's formula =INDEX($I$3:$I$18,16-(C4*8+D4*4+E4*2+F4))
 
Upvote 0
Excellent point, liveinhope. It's always a good idea to try to allow for as many possibilities as possible, especially if all it takes is adding an extra line saying "Invalid combination". Along those lines, it's also worth noting that if there is some non-numeric data in columns C:F, the formula will return a #VALUE error. That might be adequate for the OP, but if not, using IFERROR can handle that.
 
Upvote 0

Forum statistics

Threads
1,214,629
Messages
6,120,630
Members
448,973
Latest member
ChristineC

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