transcript

excelisfun - VLOOKUP: Step Aside! New Epic Lookup Function = FILTER Dynamic Array Function (EMT 1521)

Thumbnail of the video “excelisfun - VLOOKUP: Step Aside! New Epic Lookup Function = FILTER Dynamic Array Function (EMT 1521)”
Download Markdown
Community upload. AI output has not been independently verified.

Welcome to Excel magic trick number 1521. Hey, we're still talking about dynamic arrays, and this is going to be my favorite dynamic array video because we're going to see that the FILTER new array function in Office 365 is really a lookup function. And guess what? If we have VLOOKUP or INDEX, when we get multiple lookup values or have to return multiple return values, the lookup formulas get crazy, but FILTER has no problem with either one of these. Of course, the dynamic arrays are only in Office 365 right now, only the Insider Edition, but by early 2019 everyone who has Office 365 will have these dynamic arrays.

Now let's just go look at the answer right off the bat. Here's a lookup value. I need to look up Fred Meyer in this column, find all of the matches, and return all the records. There they are. If I add a second condition, which in essence means we have to look up values, I want to return the records for those two lookup values. If I get rid of Fred Meyer and only want to see that sales rep, boom, there it is. If I delete these cells, that means I want to see everything from the original data set. Now, that's only one of three examples we're going to see.

Let's go over to the sheet 1521. Our first example: we want to look up Fred Meyer and return all of Fred Meyer's sales. This is how we used to do it, with a lookup formula that looked up a single item and returned multiple matches. But here's all we have to do: equals FILTER, the array is going to be the one revenue column, comma, and then for the include, I highlight the customer column, and then I make a direct array operation with operator "are you equal to" whatever I put here, close parentheses. We will look at how to use the IF EMPTY in the next example, but right now, that is amazing. That one lookup value returns multiple items. If I change it to Amazon, instantly I get the sales for Amazon. One lookup value, multiple return values. Now, are we really calling this a lookup situation or calling it filtering? They're both synonyms, but for people who have done formulas throughout the decades in Excel, people usually refer to this as a lookup situation. Either way you slice it, lookup or filtering, that is amazing.

We'll go back to Fred Meyer. Now here's the amazing example we saw at the beginning. We're going to start off with FILTER, and I want to return all the records, so I use my diagonal black arrow up in the left-hand corner of my Excel table, comma, and for the include, since we have two conditions, I'm going to start off with open parenthesis, open parenthesis, customer "are you equal to" Fred Meyer, close parenthesis, times, and we'll do our second condition in parentheses: sales rep "are you equal to" Dow, close parenthesis. Now we need to close that off. There we have our logical test. If I press F9, we see it's a series of zeros and ones that will tell FILTER to filter that table. Control Z. Now, if there are no records to return, comma, that's where IF EMPTY comes in. I'm just going to put in double quotes "none," close parentheses, and enter. That simple formula right there, to look up values and return multiple items, is beautiful. If you rely on a data validation drop-down, which by the way you'll see in a great video a couple videos ahead, and you don't ever let the cells get empty, that's the formula. If we come up here and delete this, notice it'll tell us "none" because we set it up as an AND logical test. If I delete them both, it says "none." Control Z.

But if we want our formula to do one condition or another, a single condition, or both, or if the cells are empty and I want to see all the records, then we can amend our formula. We actually don't need these parentheses; we didn't need them before either. What we need is: if that cell is empty, I somehow need to have a vertical array of ones. Otherwise, if it's not empty, then I need to run this logical test that gives me zeros and ones to pick out the correct records for that condition. No problem. We're going to add an IF to each one of these. On the inside of the parentheses, we use ISBLANK, which checks if a cell is empty, close parentheses. If it is, comma, I need a huge array of vertical ones the same size as the table that'll pick out all the records, and we get to use another great array function: SEQUENCE. SEQUENCE(ROWS) means how many rows. I'm going to point to any one of these columns, pick the customer column, close parentheses, and ROWS will count how many rows, and deliver it to SEQUENCE: how many rows do you want, comma. We don't have any columns, comma. The start is going to be one, and watch this, comma, the step value is zero, close parenthesis, and comma. Now, the value if true. F9: there's my vertical array of ones. Control Z. Then we have a FALSE, and we have our close parenthesis.

Now I'm going to cheat and copy all of that, Control C, and in place of that parentheses I'm going to Control V. Now I have to double-click ISBLANK because I need to check that criteria cell. Just for kicks I'm going to highlight that and then click sales rep. That wasn't needed; we could have looked at any one of the columns, but that way matches up, and I'm happy with that. That will do it. We have an IF that picks out a condition for customer or a vertical array of ones, and we have the second one, a vertical array of ones or whatever the condition is. When I hit Enter, watch this: when I delete this, I get just Microsoft records. Control Z. I delete this, I get just Fam. When I delete them both, I get all of the records. Control Z. And of course, if I change it to Microsoft, Chantel, there it is. That is pretty amazing.

Now we do have one last trick we want to see. The question is simple. Here are some wrestlers, here are their weights lifted, and we need to extract from that data set based on two conditions: is the player a particular player or wrestler, and we have a hurdle. So for Buddy, we want to extract all of the date, weight lifted, and diet when the weight is greater than 250. No problem. I did a video on this. I got this question on YouTube years ago, five, six, seven years ago, and did one of our lookup formulas to try and match these two conditions and extract the correct records. Now we just use FILTER. I only want the three columns: date, weight lifted, and diet, comma, and we're going to include open parentheses, the player column "are you equal to" Buddy, close parentheses, times, in our second condition, weight lifted "are you greater than" our hurdle, close parentheses. If there are no records that match, and there we go: Buddy, weight lifts over 250. There they are. Over 400, Buddy had none. If I select Bruno, he had two. Wow, FILTER function to extract based on two conditions for some weight lifting. This is an awesome formula: for one condition, lookup; a different condition, lookup; both, or none of them, please show everything. FILTER is amazing, and then this is our old lookup function to return multiple records, or this one.

All right, if you liked that video, be sure to click that thumbs up, leave a comment, and subscribe, because there's always lots more videos to come from ExcelIsFun, including about four more amazing dynamic array videos. All right, we'll see you next video.