This is a test.
This is only a test.
Were is a real List ‘o Life, there would be… a list… or something.
This is a test.
This is only a test.
Were is a real List ‘o Life, there would be… a list… or something.
Keeping an Excel journal of my running has forced me to learn a few new tricks in Excel. The latest of these tricks is the ability to create array functions.
An array function in Excel is also knows as a Control-Shift-Enter (or CSE) function, because that’s what you have to hit (instead of just Enter) once you’ve entered the function in order to tell Excel that what you’ve just entered is an array function.
So what is an array function? Well, according to Microsoft, “An array formula is a formula that can perform multiple calculations on one or more of the items in an array.” Nice. And an array, for those of you who have never heard the term, is simply a set of values. For example:
{Monday, Tuesday, Wednesday, Thursday, Friday}
is an array of days of the week.
But back to Excel. Here’s the conundrum I was dealing with. I have a spreadsheet with the following data:
| A | B |
| Week | Distance |
| 1 | 5.5 |
| 1 | 7.9 |
| 2 | 12.3 |
| 2 | 5.3 |
| 2 | 3.5 |
Now, imagine I want to create a summary of my longest runs for each week. How is a man to manage this? Usually, finding the largest of a series of values uses the Max(RANGE) function; in Excel, this would give me the largest of a number of values. But how to select for the week? Something like CountIf would let me count up the number of instances for a given week number… and SumIf would let me sum them… but, sadly, MaxIf does not exist.
Looking for a MaxIf function, I stumbled across several references to array formulas. It turns out that, if I start with a column of week numbers, as in column D, below:
| A | B | C | D | E |
| Week | Distance | Week (Summary) | Longest Run | |
| 1 | 5.5 | 1 | ||
| 1 | 7.9 | 2 | ||
| 2 | 12.3 | 3 | ||
| 2 | 5.3 | 4 | ||
| 2 | 3.5 | 5 |
I can then create another column to display the maximum distance I’d run that week with the following:
={Max((A2:A65536=D2)*(B2:B65536))}
(Being sure to enter this formula without the curly brackets above, but hitting Control-Shift-Enter when I’m done.)
There are a couple of things to note, here:
So that’s it — my adventure in array formulas. I hope this helps someone in need of a MaxIf function!