Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
880 views
in Technique[技术] by (71.8m points)

grouping - how to assign same id for a same name (string) like dense rank to a character field in Excel

I want a dense_rank kind of formula which will return a same id for a same name in first field. Now the problem is that rank or rank.eq function in excel can be applied to value fields only but here I want a dense rank for each name.

I leave an example...

enter image description here

thanks for your help


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you just want to assign unique ID to each name use this formula in G1 (assuming your data is in F1:F16 like the screenshot below

enter image description here

Approach-1 use this formula in G1 onwards(down)

=COUNTIF($F$1:$F$16, "<="&F1)

Still if you want these numbers to start from 1 and keep on increasing so on use this formula in H1

=SUMPRODUCT((G1>=$G$1:$G$16)/COUNTIF($G$1:$G$16,$G$1:$G$16))

APPROACH-2 Without the need for creating intermediate field

=SUMPRODUCT((F1>=$F$1:$F$16)/COUNTIF($F$1:$F$16,$F$1:$F$16))

You can get results like this

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...