Calculating the change in ranking

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,653
Office Version
  1. 365
Platform
  1. Windows
Is there a way to calculate the change in rankings (+/-) in two lists that are sorted by that ranking? That is, the ranked entities are not in the same order in both lists, so I cannot compare one entity with the entity in the same row in the other list.

These are the top ten NFL teams as ranked by one odds-making website. I calculated the values in the +/- column by hand. I'd like to find a way to do it automatically.

RankTeamStart of SeasonRank+/-TeamWeek 1
#1Denver Broncos6/116.67%#1n/cSeattle Seahawks4/125.00%
#1Seattle Seahawks6/116.67%#2n/cDenver Broncos11/218.18%
#3New England Patriots8/112.50%#3n/cNew England Patriots10/110.00%
#4Green Bay Packers11/19.09%#4n/cNew Orleans Saints12/18.33%
#4New Orleans Saints11/19.09%#4+2San Francisco 49ers12/18.33%
#6San Francisco 49ers12/18.33%#6-2Green Bay Packers15/16.67%
#7Philadelphia Eagles20/15.00%#7n/cPhiladelphia Eagles20/15.00%
#8Chicago Bears26/13.85%#8+3Cincinnati Bengals25/14.00%
#9Indianapolis Colts28/13.57%#8+1Pittsburgh Steelers25/14.00%
#9Pittsburgh Steelers28/13.57%#10-1Indianapolis Colts30/13.33%

<tbody>
</tbody>

I was able to get it done with a multi-step procedure:


  1. Sort both lists by team name.
  2. Calculate the change now that the teams are on the same row.
  3. Convert the results to text.
  4. Resort both lists by rank.

This works, but it's a little tedious. Is there a way I can do it on the lists without resorting?
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
With your data in A1:I11 you can use a formula like this to return the previous rank:

=INDEX(A$2:A$11,MATCH(G2,B$2:B$11,FALSE))

Very nice. Works like a charm. Thank you.

Can this code be executed from a UDF? I'd pass it the arguments, maybe something like this:

Code:
Function PrevRank(Entity, EntityList, RankList)

   PrevRank=INDEX(RankList,MATCH(Entity,EntityList,FALSE))

End Function
 
Upvote 0
Well...


  1. Because the expression is long, obtuse, and typo-prone. A UDF call would be much clearer.
  2. Because I might want to change the expression. With a UDF I only have to change it in one place.
  3. Because I might want to do some other work, which would require additional arguments.

Is that enough? I can probably think up a few more...
 
Upvote 0
With your data in A1:I11 you can use a formula like this to return the previous rank:

=INDEX(A$2:A$11,MATCH(G2,B$2:B$11,FALSE))

I did a little research based on your suggestions. I am wondering what the difference is between your solution and this one?
Code:
   =LOOKUP(G5,A$5:A$9,B$5:B$9)

They seem to return the same results.
 
Upvote 0
I did a little research based on your suggestions. I am wondering what the difference is between your solution and this one?
Code:
   =LOOKUP(G5,A$5:A$9,B$5:B$9)

They seem to return the same results.

I see the difference now. LookUp requires that the reference list be in ascending order. Your solution works regardless of the order.

Is that correct?
 
Upvote 0
Here's a little quick and dirty function that works like the vector form of the built-in LookUp function but without the restriction that LookUpVector be sorted.

Code:
'========================================================================================
'                          My LookUp Function

' This function does what the built-in LookUp function should have done.
' It works the same way, but does not require that LookupVector be sorted.

' Syntax: =MyLookUp(LookupValue, LookupVector, ResultVector)

'   LookupValue   The value to be looked up in the Lookup vector.
'   LookupVector  The vector (row or column) where the LookupValue will be searched for.
'   ResultVector  The vector where the corresponding value will be found and returned.
'========================================================================================
Function MyLookUp(LookupValue, LookupVector, ResultVector)
Dim LookupIndex
LookupIndex = WorksheetFunction.Match(LookupValue, LookupVector, False)
MyLookUp = WorksheetFunction.Index(ResultVector, LookupIndex)
End Function

I'm sure it needs some clean up, such as declaring the vector parameters "as Range" and adding error handling. But for my needs, it works great.

All comments and suggestions appreciated.
 
Upvote 0

Forum statistics

Threads
1,222,043
Messages
6,163,566
Members
451,845
Latest member
PetarTen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top