transcript

excelisfun - Filter by rows and columns: Excel Formula for Any Version of Excel! Excel Magic Trick 1752

Thumbnail of the video “excelisfun - Filter by rows and columns: Excel Formula for Any Version of Excel! Excel Magic Trick 1752”
Download Markdown
Community upload. AI output has not been independently verified.

Introduction to problem at hand

we have gdp economic data over 3 000 rows and 46 columns and the goal from the indicator name column is to get only gdp rows and from the country column we have this huge list of countries that we need to extract and we only need the data from the columns 2000 to 2010. now i already have four videos with the help of mrexcel and bill scissors that show how to solve this problem so you can go check these out if you want to see how to do it with power query advanced filter or worksheet formulas but since these videos of course now we have dynamic array formulas so in this video we're going to see how to do it with the filter function and the bonus at the end might just blow your mind.

Microsoft 365 solution using: FILTER, SEARCH, XMATCH and ISNUMBER functions

now we're going to need the field name so i'm going to paste country and then for the year 2000 i'll enter that highlight one cell below and then drag this to the side there we go to 2010 and we'll use filter the array is going to be the inside of the table and there are a lot of empty rows in this data set so i'm going to control arrow down arrow and then i know that country has something in every row so ctrl shift down arrow ctrl shift right arrow now let's do control backspace to jump back to the active cell that's the full table we want to filter comma and for include our first condition we'll start right below indicator name control shift down l control backspace anytime you are equal to gdp and we'll just see what this returns close parentheses close parentheses and sure enough it shows only rows with gdp now we have to deal with the country and we're given the country all in one cell if this was a column then we'd use a slightly different approach but luckily we got everything in a single cell now this is a spilled array formula so the top left cell houses the formula all the other cells have a ghost of the formula but the formula doesn't really live there so we'll f2 in the top cell and edit we have a second condition we need to put in to include and this is an and logical test because both have to be true and we use multiplication when we're doing an and logical test now the goal is from the country column over there to check all of these different countries well we can actually do this with the search function and normally we put a single item into fine text but i'm going to put that whole column so control left arrow down arrow control shift down arrow control backspace so in find text i'm doing a function argument array operation it's going to give me an answer for each country in that column and the answer will be did it find that country name in this single cell text string and it'll give me the position where it found it comma the within text that's the single cell with all the country names close parentheses now if we highlight just this part and hit f9 we get a bunch of value errors but in some of the positions it returns a number where it found the country so what we're interested in are the numbers control z so we wrap is number around search close parentheses and now when i hit enter we have filtered by gdp and only the countries where the country name is listed in that cell now the next task is to filter the column so in the top cell we're going to hit f2 now if i highlight this and hit f9 we want to notice something about this resultant array curly brackets always house the array comma means go over a column and when we see a semicolon that means go down a row so this array has rows and columns but our next task is to filter this by the columns control z so that means we use a second filter there's the entire table comma and in include what we need to give it is trues and falses across the columns now whatever array we put here of trues and falses has to be the same size as the original table and we have the names of the fields that we want so let's compare two lists of item using x match now the lookup value normally we give it one item but we're going to give it the entire 46 column field name so control shift left arrow control backspace that'll do a function argument array operation delivering an answer for each column comma and these are the items we're looking up close parentheses and now if we evaluate this with f9 you can see that's an array but there's only columns represented by commas and once again what we're interested in are the numbers so control z is number and close parentheses that's our formula when i hit enter there's the resulting table now i actually already added some number formatting here so if i control 1 to open up format cells i use this custom number formatting to display the numbers in millions click ok and it indicates millions up here now this is the dynamics build array formula that can accomplish this task and we saw four videos so far but i want to show you one of the solutions and this is going to be way old school.

Any version of Excel solution using: Advanced Filter and the AND, SEARCH and ISNUMBER functions.

so on this sheet right here if i added a column and simulated the and logical test remember we had to use is number and search but this time we're going to do it one cell at a time and then we're also checking to see whether the record includes gdp if i copy this formula down double click and send it down the formula works row by row but here's the amazing thing control z if you have a helper column that would go into a column next to the table you can actually use this formula with advanced filter and behind the scenes in memory advanced filter will take the formula copy it down and figure out which rows to use and here's all you have to do for advanced filter now you have to know the formula that you would copy down you put it in a cell and the cell above it cannot have one of the field names you can leave it empty or put some words then list the column names that you want i'm going to click in a single cell actually i left this over here i'm going to ctrl shift down arrow ctrl shift right arrow control backspace that got me back to the active cell but i actually wanted the other corner watch this control period gets me to the other corner and now when i go up to data we never thought we'd have to use this again advanced filter i want to copy to another location there's the table the criteria range this is where you put the formula that would be copied down cell above and formula and the copy to this is where we put the names for the fields we want to extract and that's it advanced filter will do all the rest when i click ok that is amazing and advanced filter is sort of automatic control f3 to open up name manager it automatically creates a criteria and extract range the extract is that right there and so if some data over here changed like the actual numbers or something like that we could just rerun advanced filter and it remembers everything now of course you would come over here and control 1 custom we're going to put a comma and then one two commas at the end where each comma represents three zeros that's displaying in millions click ok so i don't know it seems like this advanced filter and formula that seems easier than that filter formula so i want to hear what you guys think what do you think of this advanced filter and what do you think of the filter function.

Conclusion and call for viewers to comment and tell us which one you like!!

alright if you like that video be sure to click that thumbs up leave a comment and subscribe because there's always lots more videos to come from excel is fun here's some of the older videos if you want to go check these out.

Closing Video Links