Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Creating labels for data based on first 3 characters in cell in excel

I have a column with ID numbers, and the first three characters indicate a label of interest I want to create in a separate column.

The first three characters of ID and labels are as follows:
182: turtles, 187: rabbits, 196: cats, and all the rest are "None". An example output which I did manually looks like this:

example output

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I’m a novice at excel, and attempted a formula which was something like this but couldn’t figure out how to finish it or make it work:

a feeble attempt

The actual data is too much to actually do manually. I’m open to whatever approach works. Thank you.

>Solution :

Try: Using XLOOKUP()

enter image description here


• Formula used in cell B2

=XLOOKUP(LEFT(A2,3)+0,{182,187,196},{"Turtles","Rabbits","Cats"},"None")

Or, You can #SPILL! as an array.

=XLOOKUP(LEFT(A2:A15,3)+0,{182,187,196},{"Turtles","Rabbits","Cats"},"None")

Few other alternatives:

enter image description here


• Formula used in cell C2

=IFERROR(IFS(LEFT(A2,3)+0=182,"Turtles",LEFT(A2,3)+0=187,"Rabbits",LEFT(A2,3)+0=196,"Cats"),"None")

• Formula used in cell D2

=SWITCH(LEFT(A2,3)+0,182,"Turtles",187,"Rabbits",196,"Cats","None")

• Formula used in cell E2

=IFERROR(CHOOSE(SUM(N(--LEFT(A2,3)={182,187,196})*{1,2,3}),"Turtles","Rabbits","Cats"),"None") 

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading