Oh, Wait! Excel doesn’t have those functions. We’ll have to roll our own. We’re going to use the Double Unary tip found here. In Excel, 1*TRUE = 1, 0+TRUE = 1, TRUE^1 = 1, and minus-minus TRUE (–TRUE, the double unary) = 1. It’s two sign changes, and thought to be the best way to turn an array of TRUE/FALSE into ones/zeros. Multiplying an array of parameters by an array of ones and zeros leaves only the TRUE parameters non-zero.
Back to our list of the 122 major teams in professional sports, the Boss has decided that sorting by name length, then alphabetically, isn’t going to do. He wants it by name length by stadium size. So, thanks to Wikipedia, your data looks like this, Column(F) is arena size:
D | E | F | |
---|---|---|---|
1 | Anaheim Ducks | 13 | 17,174 |
2 | Arizona Cardinals | 17 | 63,400 |
3 | Arizona Diamondbacks | 20 | 48,633 |
4 | Atlanta Braves | 14 | 50,097 |
5 | Atlanta Falcons | 15 | 71,228 |
6 | Atlanta Hawks | 13 | 18,729 |
7 | Baltimore Orioles | 17 | 45,363 |
8 | Baltimore Ravens | 16 | 71,008 |
9 | Boston Bruins | 13 | 17,565 |
10 | Boston Celtics | 14 | 18,624 |
Using fzz’s comment about the ROW() function, we’ll sort the length by G1=LARGE($E$1:$E$122,ROWS($G$1:$G1)) filled down. The table looks much like before:
D | E | F | G | |
---|---|---|---|---|
1 | Anaheim Ducks | 13 | 17,174 | 29 |
2 | Arizona Cardinals | 17 | 63,400 | 22 |
3 | Arizona Diamondbacks | 20 | 48,633 | 22 |
4 | Atlanta Braves | 14 | 50,097 | 22 |
5 | Atlanta Falcons | 15 | 71,228 | 21 |
6 | Atlanta Hawks | 13 | 18,729 | 21 |
7 | Baltimore Orioles | 17 | 45,363 | 21 |
8 | Baltimore Ravens | 16 | 71,008 | 20 |
9 | Boston Bruins | 13 | 17,565 | 20 |
10 | Boston Celtics | 14 | 18,624 | 20 |
We know there are only three teams of name length 22. A formula – -($E$1:$E$122=22), using the double unary operation, gives us an array of 119 zeros, and just 3 ones that line up on 22. If we multiply that array by the array of arena capacities (F1:F122) we have 119 multiplications by zero, and three multiplications by 1. A MAX() function or an equivalent LARGE(,1) function on that array product returns the capacity of largest stadium hosting a team name 22 letters long. Those equations formulas, array entered, would look like this:
- {=LARGE(- -($E$1:$E$122=22)*$F$1:$F$122,1)}
- {=MAX(- -($E$1:$E$122=22)*$F$1:$F$122)}
We want to modify those for different teams. Changing the =22 to =$G1 is a start, and we’ve gone about as far as we can with our ‘MAXIF().’ It’s going to return the same thing three times. A scheme using COUNTIF() starting from the top and working down will improve the ‘LARGEIF()’. Using mixed references, $G$1:$G1 will grow as we fill down. COUNTIF($G$1:$G2,$G2) will only count one 22, COUNTIF($G$1:$G3,$G3) will count two 22s, and COUNTIF($G$1:$G4,$G4) will count 3, and that’s all there are. This array-entered equationformula then, filled down, is ‘LARGEIF()':
- {=LARGE(- -($E$1:$E$122=$G1)*$F$1:$F$122,COUNTIF($G$1:$G1,$G1))}
In I1 filldown =MATCH(H1,$F$1:$F$122,0) and in J1 filldown =INDEX(D:D,I1). Your table should look like this:
D | E | F | G | H | I | J | K | |
---|---|---|---|---|---|---|---|---|
1 | Anaheim Ducks | 13 | 17,174 | 29 | 45,389 | 52 | Los Angeles Angels of Anaheim | |
2 | Arizona Cardinals | 17 | 63,400 | 22 | 19,980 | 95 | Portland Trail Blazers | |
3 | Arizona Diamondbacks | 20 | 48,633 | 22 | 19,356 | 63 | Minnesota Timberwolves | |
4 | Atlanta Braves | 14 | 50,097 | 22 | 18,144 | 30 | Columbus Blue Jackets | |
5 | Atlanta Falcons | 15 | 71,228 | 21 | 43,651 | 89 | Philadelphia Phillies | |
6 | Atlanta Hawks | 13 | 18,729 | 21 | 19,596 | 42 | Golden State Warriors | |
7 | Baltimore Orioles | 17 | 45,363 | 21 | 18,203 | 83 | Oklahoma City Thunder | |
8 | Baltimore Ravens | 16 | 71,008 | 20 | 68,756 | 69 | New England Patriots | |
9 | Boston Bruins | 13 | 17,565 | 20 | 67,164 | 49 | Jacksonville Jaguars | |
10 | Boston Celtics | 14 | 18,624 | 20 | 65,857 | 108 | Tampa Bay Buccaneers |
Column(I) shows the indices reordered by size of the arena.
There are some problems with this approach. It only works with positive numbers, such as our capacities. Negative numbers will be less than a FALSE, and a zero will be returned in their place. And if ever capacities are equal, it will always return only the first (same old problem). Nicely here, hockey and basketball held in the same arena draw to different capacity. The file is available at http://wl.filegenie.com/~JMOprof/LargeIF.xls
…mrt
©¿©¬