Forum Discussion
Using FILTER function and VSTACK function together
OK. Firstly, are you using 365 online or a desktop version of Excel (I use only the desktop version but I believe the on-line version lacks a Name Manager)?
I have assumed that the data held on your 10-15 worksheets are all located in the same place on each sheet. That allows one to use a 3D range that spans multiple consecutive sheets, if not, a different strategy would be needed. The syntax of a 3D range is
"productList"
Products:Clearance!$A$2:$A$21That is the name of the first sheet, followed by a 'colon' symbol, then the name of the final sheet of the range, and closing with an 'exclamation mark'. That string may be enclosed in single quotes if needed.
The sheet range is followed by a worksheet range that applies to every sheet.
From there TOCOL or VSTACK may be used to consolidate the data into a single array held in memory (here called 'consolidatedList'). I have used TOCOL because it allows the blank rows to be eliminated immediately, but the use of FILTER would have removed them in any case.
= LET(
consolidatedList, TOCOL(productLists, 1),
FILTER(
consolidatedList,
ISNUMBER(SEARCH(selectedCompany, consolidatedList))
)
)I expect you will have more questions but first let's see whether this helps.
I am still confused. I am sorry, I have not used Microsoft Excel for a long time.
So is "selectedCompany" referring to the Company Name?
Does the data have to be formatted into tables?
Do I have to name the tables or ranges?
- PeteSaucesFeb 21, 2024Copper ContributorGreat!! Now, how do I copy and paste the results of that formula for each "company" into a seperate workbook??
- PeterBartholomew1Feb 21, 2024Silver Contributor
The final formula is pretty much as before. If though, we switch to using VSTACK because it applies to entire tables and that is the function used in the videos, we get
= LET( consolidatedList, VSTACK(productLists), FILTER( consolidatedList, ISNUMBER(SEARCH(selectedCompany, consolidatedList)) ) )The name 'consolidatedList' is used for a partial calculation within the formula but does not appear anywhere on the worksheet and only exists in memory while the LET function is being evaluate [i.e. the LET function defines the scope of the name; the name simply does not exist outside that scope].
If you are thinking "WTF, this looks nothing like the spreadsheets I was brought up on!", I can only agree. For me that is something of a relief; you might find it somewhat more challenging!
- PeteSaucesFeb 20, 2024Copper ContributorPeterBartholomew1
So what would be the final formula? - PeterBartholomew1Feb 20, 2024Silver Contributor
Yes, it is possible. In fact that is what the formulas do. I show a consolidated list, but that is only for information. If it is deleted the filtered lists still work.
BTW. Separate tests to determine whether the row is blank and whether the company matches the selection are unnecessary. A blank row automatically fails the test so does not appear in the filtered result.
- PeteSaucesFeb 20, 2024Copper Contributor
Ok. So I do not want to consolidate all of the data into another sheet.. instead I would like filter all of the data in the seperate sheets without consolidating them, and show the results of what has been filtered..Please let me know if this is possible.
Peter
- PeterBartholomew1Feb 20, 2024Silver Contributor
Yes, it is virtually the same formula as the one we are already working on and it would address your problem, as would
which includes a bit of amateur theatricals!
I use named references for everything (including the 3D reference) but that is because my strategy is "if I know what a value represents, I name it to provide meaning; if I don't know what a value represents, I delete it to avoid misuse!" Not everyone would get on with that as a strategy!
- PeteSaucesFeb 20, 2024Copper ContributorPeterBartholomew1
I am trying to use exactly the same type of formula used in this YouTube video, but it is not working.... So I am wondering how to use a similar strategy...
https://www.youtube.com/watch?v=Au-j0ytEqF4
Please let me know.
Peter - PeterBartholomew1Feb 20, 2024Silver Contributor
Thanks SergeiBaklan. If you see other communication gaps, please chip in!
If you look at the last formula I posted, you will see something that may look like code but is, in fact, simply a worksheet formula that may be placed anywhere on the sheet that you wish to see the result. If you have defined the 3D range 'productLists' in Name Manager, you could simple type
= TOCOL(productLists, 1) or = VSTACK(productLists)into a cell and either should return your tables stacked down the sheet (see the 'Consolidated' worksheet). As you need to apply further transformations to the data, traditional spreadsheet practice would be to wrap that bit of the formula within a further function, repeating the calculation as many times as you need to use it.
What the LET function allows you to do, is perform the first part of the calculation and assign the result to a variable, here called 'consolidatedList'. This array is then used twice in the FILTER formula without needing to be first output to a helper range.
- PeteSaucesFeb 20, 2024Copper ContributorPeterBartholomew1
I am still confused.. How do I get the "consolidatedList"? - SergeiBaklanFeb 20, 2024Diamond Contributor
If open the file PeterBartholomew1 shared in one of previous posts, all names are here
Ranges, no tables.