In Excel, get unique members in order and number them
In the Excel table below, there are duplicate values in column A:
A  |  
  |
1  |  
   Cow  |  
  
2  |  
   Chicken  |  
  
3  |  
   Horse  |  
  
4  |  
   Butterfly  |  
  
5  |  
   Cow  |  
  
The task is to number column A in order with natural numbers while making duplicate values take the same number. Write the corresponding numbers in the next column on the right:
A  |  
   B  |  
  |
1  |  
   Cow  |  
   1  |  
  
2  |  
   Chicken  |  
   2  |  
  
3  |  
   Horse  |  
   3  |  
  
4  |  
   Butterfly  |  
   4  |  
  
5  |  
   Cow  |  
   1  |  
  
Use SPL XLL to enter the formula below and drag the first cell down all the target cells:
=spl("=?2.conj().id@u().pos(?1)",A1,A$1:A$5)
 

Or we can use a dynamic array formula to get the results at a time:
=spl("=(y=(x=?1.conj()).id@u()),x.(y.pos(~))",A1:A5)
 
In the above formula, conj()function concatenates values in the specified range of cells into a one-dimensional arrary; id() function get the unique members and works with @u option to not to re-sort the array; pos() function get the position of each member.
SPL Official Website 👉 https://www.esproc.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProc_Desktop/
SPL Learning Material 👉 https://c.esproc.com
Discord 👉 https://discord.gg/sxd59A8F2W
Youtube 👉 https://www.youtube.com/@esProcDesktop
Linkedin Group 👉 https://www.linkedin.com/groups/14419406/