Introduction
Welcome to Excel Magic Trick 1922. In this video, we're going to see how to create a dynamic spill array formula for bank reconciliation. Last video, 1921, we did formulas where we entered them into a cell and copied them down. But dynamic spill array formulas are going to be totally different. Why do we have to do two different formulas for my book balance and a bank balance? Because anytime you have an account, a bank account or a credit card account, there are two people watching that account. All the items we enter into our books, our formula is going to have to look at every single one. But the bank balance, if there's not a Y in this column, for example, that deposit of 8,200, the bank formula cannot account for it yet until we put a Y and then the formula updates. All right, let's see dynamic spill array formulas.
Single Input, Single Output Formula and how they are different than Dynamic Spilled Array Formulas
Here's the formula we did last video. This formula is called a single input, single output formula. Notice we're looking at single cells, including the cell directly above, which is always going to be the previous balance. These are single inputs, and the formula delivers a single answer. But with dynamic spilled array formulas, we're going to create a single formula, and it will automatically spill the results down the column. We don't have to manually copy. And later, when you have to edit, you only edit in a single cell.
So I entered this. Notice I have to manually copy it down. Go to the last cell. Check F2 to make sure all the cell references are pointing in the right place. And then if I want to edit, I come to the top cell, F2. Let's say I want to change it to say "no B" for no balance. I have to enter the formula and recopy it down. But with dynamic spill array formulas, we just create a single formula and it does the rest. Control Z, Control Z, F2.
Why we need to use SCAN function rather than just arrays in the formula, and why Aggregate Formulas can NEVER spill an array of values
Often we can simply take a formula like this single input, single output, copy, escape, come over here, F2, RLV, and change the single inputs to the entire array. F4, that's going to be the entire In column minus E4, that's the Out column. But the problem with this is that aggregate functions like SUM, MAX, MIN, and AVERAGE can never spill a dynamic array. Why? Because the definition of aggregate is to take a bunch of inputs and deliver a single answer. So if I try this, it's going to spill, but it gives me one single answer for the whole column, the last number right there.
Microsoft knew that there was this dynamic spilled array problem with aggregate functions, so they invented functions like BYROW and SCAN. SCAN is the function we're going to use because SCAN can give us a running total, always looking at the previous balance in the array of numbers that we give it. When we use SCAN here, we're not going to say in cell minus out cell. We're going to convert these two columns to a single column, and then SCAN will just calculate a running total. How I do that is if I subtract the whole Out column from In, I get a single column with positive 5,395, minus 31, minus 37.95, minus 4,200, plus 1,125, and so on. Once we have a single column instead of two, we can just use SCAN to get a running total.
SCAN function to calculate a Running Total. SCAN function is the Dynamic Spilled Array function that can invoke a Relative Cell Reference in a Dynamic Spilled Array Formula
This is a dynamic spill array formula. Normally with formulas like single input, single output, you have to highlight all of them and then hit Delete. Watch this. If I just delete the top cell, it deletes only that single formula. Control Z to undo. But this is a dynamic spill array formula, so when I delete the top cell, it deletes the only formula. We entered the formula in the top cell, and it was spilling everything. So now we simply type equals, the whole In column minus the whole Out column, and when I hit Enter there's our single column. Now we can just say, hey SCAN, please do a running total.
The differences between deleting Single Input, Single Output formulas and Dynamic Spilled Array Formulas
Dynamic spill array formulas are much different than single input, single output. I want you to click in the top cell and look. In the formula bar you can see there's a formula in every single cell. But with dynamic spilled array formulas, that formula only lives in the top cell. All cells below have ghost formulas, and those ghost formulas mean there's nothing in the cell.
SCAN Formula for My Book Balance
Now we can do our running total with SCAN. F2, after the equal sign, SCAN. We need an initial value, and over here we had to click one cell above, and when we manually copied down, it always looked at the previous one. But since we have a single column here, if we put the SUM function into the function argument of SCAN, it will always add the previous value to the current value for every row. That's exactly what we want. So the initial value here is not one cell above. It's just zero, because what does that do? It says zero plus 5,395, which is 5,395. When it gets to the second row of the dynamic spilled array, it looks at the previous value and adds the minus 31, which gives us the correct balance. So the array is the two columns minused, then for the function we use the SUM function. That's our formula. Close the parentheses and enter. You can see it works perfectly.
Dynamic Spilled Array Formulas only live in the top cell
We'll turn this off down there. There's the ghost. The formula lives only in the top cell.
Remaining cells contain Ghost Formulas
Those cells below contain ghost formulas, and those ghosts are part of the dynamic spilled array formula. If you press F2 on one, it looks empty, but it isn't really empty.
Why Dynamic Spilled Array Formulas are so convenient
We're only dealing with a single cell whether we're creating or editing. That's what makes dynamic spill array formulas so convenient.
Referencing Ghost Formulas in a Dynamic Spilled Array
Now, that number right there, F2. What? Nothing there. Well, I'm free to reference that, minus 3,795. From that little ghost right there, the formula knows to go and get it and bring it over to whatever other formula you're using. Control Z.
Editing a Dynamic Spilled Array Formula
To turn this off, notice I'm going to edit. F2. After the equal sign, IF, ISNUMBER, and I highlight the entire column. It better be exactly the same number of rows and columns as the other arrays. That's the value, close, comma. If I click on the logical test and hover, all of those TRUEs pick out the spilled numbers. The FALSEs are the ones where we want to hide all the numbers down there. So we come to the end. That's the value_if_true, the number we want to see, comma, then value_if_false, double quote, double quote. That's a zero length text string. That's the syntax to show nothing in a formula. Close, Control Enter. That is a thing of beauty. Notice I did not have to enter the formula and recopy it down. That edited formula just spilled the results.
IF and ISNUMBER functions
The IF function checks the logical test and returns one value when it is true and another when it is false. ISNUMBER returns TRUE for numeric values and FALSE for everything else, which is how the spilled numbers get filtered.
Zero Length Text String
The double quotes with nothing between them form a zero length text string. That is the syntax to show nothing in a formula.
Test Formula
If we test it, when I put a date here, the formula should show up. 12/3, tab. Sure enough, it does. I'm going to subtract $1, and that formula is working.
SCAN Formula for Bank Balance
For the bank balance, we have to exclude values when there's not a Y in the reconcile column. So we just amend this. I'm going to copy this in edit mode, Control C, tab, tab, F2, put it in edit mode, Control V. If I highlight the array and hover, those are all the numbers. But I want, for example, the $8,277.36 entry to either be zero or, in our case, to use an IF function to put FALSE there. Since FALSE is ignored by the SUM function, the running total will ignore it. Right before the array I say IF, and for the logical test, is the reconcile column equal to "Y"? Because that's text, any of those that match come out TRUE. Well then I want the value_if_true, otherwise I want FALSE.
Why Omitting value_if_false argument in the IF is efficient
I don't even have to put that argument in. I could put a zero, but that's a wasted keystroke, so I backspace. If I leave value_if_false omitted, a FALSE is put in, and since the SUM function ignores FALSE, I leave it as is and close the parentheses. If we highlight this, there's the array we want. Notice in the sixth position that $8,277.36 is not there. FALSE is there, SUM will ignore it, and that's our formula. When I enter the correct values, it spills down the column from the top cell. There's the formula. All the remaining cells are those ghosts, part of the dynamic spilled array formula. F2, it's not really there, but it is. Equals. If I needed it in some other formula, I reference it and there it is.
Summary
Last video we did single input, single output for my book balance and bank balance. This video we did dynamic spilled array formulas using SCAN, IF, and ISNUMBER, and then for the bank balance we had to add an extra IF.
Closing
We'll see you next magic trick.
