transcript

excelisfun - Excel Magic Trick 1354: Rank with Criteria: Rank Football Teams by Total Wins & Division Wins

Thumbnail of the video “excelisfun - Excel Magic Trick 1354: Rank with Criteria: Rank Football Teams by Total Wins & Division Wins”
Download Markdown
Community upload. AI output has not been independently verified.

Welcome to Excel Magic Trick number 1,354. If you want to download this Excel workbook, Excel Magic Trick 1354, so you can follow along, click on the link below the video. Hey, we've got a great video here. We get to see how to rank with conditions or criteria. In particular, we're going to rank football teams by total wins and division wins. Here are our football teams and the total wins, but you can see right here that New York Giants, SF, St. Louis, and Minnesota all have eight wins. So if we rank them, we also want to use the secondary condition, division wins. I've already sorted the data set, so this is the perfect order. Whatever the ranking, New York Giants would be first, San Francisco would be next, and then St. Louis and Minnesota, because they're tied, would get the following rank. No problem. We need to rank on two different columns, and we can simply use the RANKIF function. Now, there is no RANKIF function, so we're stuck with these three ranking functions: RANK.AVG, RANK.EQ, and RANK. RANK.EQ and RANK.AVG came in Excel 2010. RANK was an older function. RANK is the same exact function as RANK.EQ, but they added RANK.AVG as a new function in 2010. They wanted to keep with this dot convention, so they replicated what's called a compatibility function and gave it an extension. RANK.EQ will assign the same rank for each tie, and RANK.AVG will average the ranks if there's a tie. We're going to start by looking at RANK.EQ. The first argument is the number of wins to rank, the relative reference. The second argument is the reference, which is all the numbers to compare against. I need to hit the F4 key to lock that reference. Then the order argument is descending or ascending. We want the most wins to be first, so we use descending by putting a zero, close the parentheses, press Ctrl+Enter, double-click, and send it down. Just as RANK.EQ would suggest, when it gets to eight wins, they all get the same rank, and that's not what we want. Since we're looking at division wins as our second condition, this should be seven, but it should not be seven. It should be eight. In essence, we need to add one there, because there's one team above San Francisco. When we get down to St. Louis and Minnesota, this should not be tied at seven; it should be nine and nine. The reason is that St. Louis has two teams above them, so to the seven we need to add two, which gives us nine, and the same with Minnesota. We're going to amend that formula by adding a small formula element to the end to give us a zero here, a one here, and a two and a two. Those are the numbers we need to add to the sevens to get our eight, nine, and nine. Let's delete that, and we'll use the COUNTIFS function. We're going to have two conditions. The first criteria range will be the wins column, and I'm going to use the F4 key to lock that reference. The condition is how many records have eight wins, which is a relative cell reference that will change as we go up and down. The second condition is the division wins column, F4 to lock it, and our condition is how many division wins are greater than the value for this record. I had to put the comparison operator in double quotes and join it with the ampersand to that relative cell reference. Notice that the COUNTIFS function performs an AND logical test. When I ask how many of these records have eight wins and how many have greater than four division wins, the answer is zero, because it can only ask the question of the records where there are eight wins. That is our formula. Close the parentheses, press Ctrl+Enter, and double-click to send it down. Look at that: that is exactly what we need. Zero, one, two, and two. When COUNTIFS asks the question here, it says how many records are eight and how many are greater than three. There's only one, and when it gets down here, the question is how many have eight wins and division wins greater than two. That's one, two. So that's the small formula element we can add to our RANK.EQ. I'm going to copy this, then go into edit mode on my rank formula, highlight it, press Ctrl+C, escape, and then put the copied formula in edit mode right after the equal sign. I'll press Ctrl+V and add the plus sign. There it is: our ranking, plus that extra little bit. We could have put the rank at the end also, but there you go. Ctrl+Enter, double-click, and send it down. You've got to be kidding me. Look at that: perfect ranks of seven, eight, nine, and nine. Not only that, but down here for this tie we get twelve and thirteen, and this one is fourteen, because yes, they're tied with five wins, but they both had one division win. All right, that was a lot of fun ranking with two conditions for football total wins and division wins, using RANK.EQ and COUNTIFS. We'll see you in the next video.