Home » excel » excel – Recalculate unique rank with autofilter?

excel – Recalculate unique rank with autofilter?

Posted by: admin April 23, 2020 Leave a comment

Questions:

Because I have a lot of items that rank at 1 (or 100%), I’m using this formula to get a unique rank as you can see in the image below under “Filtered Unique Rank”:

=RANK(A2,$A$2:$A$1000)+COUNTIF($A$2:A2,A2)-1

This was my old Rank formula under “Regular Rank”, which essentially showed a lot of items ranking at 1:

=RANK(A2,$A$2:$A$1000)

enter image description here

This is the formula I was using to get rankings based on a filter, but it’s NOT unique:

=SUMPRODUCT(SUBTOTAL(3,OFFSET($A$2:$A$1000,ROW($A$2:$A$1000)-MIN(ROW($A$2:$A$1000)),0,1)),--(A2<$A$2:$A$1000))+1

Question: Based on the info above, is there a way to get a unique rank from an autofilter?
Source of above formula: http://www.mrexcel.com/td0067.html

How to&Answers:

Say the data is like:

unfiltered

Column B is filled with the formula for the “standard” unique, sequential rank, so B2 contains:

=RANK(A2,$A$2:$A$10)+COUNTIF($A$2:A2,A2)-1

In D2 we enter:

=IF(SUBTOTAL(3,$B2:$B2)=0,"",A2)

and copy down. The helper D column resembles column A except if the row is hidden, the value is a blank. In E2 we enter:

=RANK(D2,$D$2:$D$10)+COUNTIF($D$2:D2,D2)-1

and copy down.

Here is a snap with the filter applied:

filterapplied

Note column E produces a simple, unique, sequential rank.

Answer:

Try this array formula**:

=INDEX(FREQUENCY(IF(SUBTOTAL(3,OFFSET($A$2,ROW($A$2:$A$10)-MIN(ROW($A$2:$A$10)),,,)),$A$2:$A$10),A2),2)+INDEX(FREQUENCY(IF(SUBTOTAL(3,OFFSET($A$2,ROW($A$2:A2)-MIN(ROW($A$2:A2)),,,)),$A$2:A2),A2-{0.00001,0}),2)

Regards

**Array formulas are not entered in the same way as ‘standard’ formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you’ve done it correctly, you’ll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

Answer:

No, you can’t change the values passed to formula by using autofilter. The formula will still refer to the same count and values, whether they appear hidden or not.

However, you can achieve this by using pivot table filters as they render the content of cells by changing their values.