# Rank only if criteria is met, and omit null/zero values

1. ## Rank only if criteria is met, and omit null/zero values

Hi.

I've been pulling my hair out with this one.

I have a column of values that I wish to rank. Let's say the values are profit made in a month for each operational site. However, there is another column which contains the state that that site is in. Finally, there is a column with actual name of the site. I have a massive list and eventually on another tab I am going to grab/lookup/match up the five sites with the worst performance (in this case, the lowest profit), listing their name.

I want to be able to repeat this trick for other metrics (say, operating costs, number of OHS incidents etc.), always referring to another column with the state in it, so that I get the best/worst performers for each state.

So if that isn't hard enough, I also wanted to be able to easily choose whether the highest or lowest number is the highest 'ranked' (i.e. in number 1 place, just like you can with a basic rank function) and also omit null values and 0 values.

See attached sheet. Thinking about it now, if it's easier to just straight away get the Summary tab picking up things, rather than doing that intermediate step in the Data tab, then this would probably be better.

Any ideas?

I've been through so may iterations of rank, countif, countifs etc. Oh, and my sorting/filtering doesn't seem to be an option, so ignore this.

Cheers!

2. ## Re: Rank only if criteria is met, and omit null/zero values

Try this formula in Data sheet cell G2 copied down

=IF(B2="NY",COUNTIFS(B\$2:B\$14,B2,C\$2:C\$14,"<>0",C\$2:C\$14,">"&C2)+1,"")

Same formula for H2 except for "NY" changed to "CON"

[Note: this ranks highest figure as 1, change ">" to "<" to reverse]

Now in Summary sheet you can use this formula in C2 copied to C3

=INDEX(Data!C\$2:C\$14,MATCH(1,INDEX((Data!\$B\$2:\$B\$14=A2)*(Data!\$G\$2:\$G\$14=B2),0),0))

3. ## Re: Rank only if criteria is met, and omit null/zero values

Mate, that's awesome. Thanks a lot!

There are currently 1 users browsing this thread. (0 members and 1 guests)