I want to have an Arrayformula at A1 to produce this output:
I want to have a different serial numbering for different names. There can be any number of names, names would not be sorted & could repeat any number of time.
You may try:
=vstack("Header",
map(B2:B,lambda(Σ,if(Σ="",,countif(B2:Σ,Σ)))))
Alternate formula:
=arrayformula(if(len(B2:B),countifs(B2:B,B2:B,row(B2:B),"<="&row(B2:B)),))