Hi people!!
I'd like to give a "similarity" score to each code from a list of 4-digit codes:
1321
1311
1311
3533
4925
1389
4922
If one of the codes has the same first 4 digits than another code, it will receive a score of 4. If it has the same first 3 digits, a score of 3, and so on until 0.
The result of the above list should resemble to this:
1321 2
1311 4
1311 4
3533 0
4925 3
1389 2
4922 3
Is it possible using an Excel formula?
Your help is very much appreciated!
Last edited by glux; 02-07-2012 at 04:14 AM.
I'm attaching the list so you can practice ;-) target-to-target similarity 3.xlsx
A bit long winded but try this in B2
Drag/Fill Down.=MAX(IF(COUNTIF($A$2:$A$8,A2)-1>0,4,0),IF(SUMPRODUCT(--(LEFT($A2,3)=LEFT($A$2:$A$8,3)))-1>0,3,0),IF(SUMPRODUCT(--(LEFT($A2,2)=LEFT($A$2:$A$8,2)))-1>0,2,0),IF(SUMPRODUCT(--(LEFT($A2,1)=LEFT($A$2:$A$8,1)))-1>0,1,0))
This should also work
These will return the values requested in post #1, in your attached sample the expected result differs.=MAX(IF(COUNTIF($A$2:$A$8,A2)-1>0,4,0),IF(SUMPRODUCT(--(INT($A2/10)=INT($A$2:$A$8/10)))-1>0,3,0),IF(SUMPRODUCT(--(INT($A2/100)=INT($A$2:$A$8/100)))-1>0,2,0),IF(SUMPRODUCT(--(INT($A2/1000)=INT($A$2:$A$8/1000)))-1>0,1,0))
Last edited by Marcol; 02-07-2012 at 03:53 AM. Reason: Added attachment
If you need any more information, please feel free to ask.
However, if this takes care of your needs, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED. It helps everybody! ....
Also
If you are satisfied by any members response to your problem please consider using the small Star icon botom left of thier post to show your appreciation.
Hey Marcol!!! Thanks so much!! It's working!!
Great job!
It's actually the first step of a much more complex problem...
But I will create a new post for the next step... and I will mark this post as SOLVED cause I like to see solved problems in this forum!! ;-)
Hello Marcol... if you would like to help with the next step of my problem... here's the thread: http://www.excelforum.com/excel-2007...93#post2701493...
... there's gonna be a 3rd step ;-)
Hello Marcol, the 2nd step was solved already!! Now I still have one final step: if you want to help, here's the thread: http://www.excelforum.com/excel-2007...26#post2701526
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks