How to use FILTER() to eliminate columns AND rows by criteria?

TheMacroNoob

Board Regular
Joined
Aug 5, 2022
Messages
52
Office Version
  1. 365
Platform
  1. Windows
I don't have access to VSTACK yet, so I am using a workaround to stack many dynamic arrays on top of each other in a list.

To do this, my helper array formula is as follows:

=LET(NUMCols,COLUMNS(Sheet1!C6:E15),RowsA,ROWS(Sheet1!C6:E15),RowsB,ROWS(Sheet2!C6:E15),SeqCol,SEQUENCE(RowsA+RowsB),SeqRow,SEQUENCE(1,NUMCols),Result,IF(SeqCol<=RowsA,INDEX(Sheet1!C6:E15,SeqCol,SeqRow),INDEX(Sheet2!C6:E15,SeqCol-RowsA,SeqRow)),Result)

This results in the following:

EMT1529.xlsx
HIJ
4Helper
5BuildingDamagedDeductible
61Yes72762
72Yes61570
83Yes61849
94Yes71001
105Yes71044
116Yes96660
127Yes110792
138Yes75367
149Yes59733
1510Yes78861
16AYes107967
17B0112415
18C0118634
19D076366
20EYes111093
21F0103157
22GYes64347
23HYes60256
24I062276
25JYes94330
Sheet3
Cell Formulas
RangeFormula
H6:J25H6=LET(NUMCols,COLUMNS(Sheet1!C6:E15),RowsA,ROWS(Sheet1!C6:E15),RowsB,ROWS(Sheet2!C6:E15),SeqCol,SEQUENCE(RowsA+RowsB),SeqRow,SEQUENCE(1,NUMCols),Result,IF(SeqCol<=RowsA,INDEX(Sheet1!C6:E15,SeqCol,SeqRow),INDEX(Sheet2!C6:E15,SeqCol-RowsA,SeqRow)),Result)
Dynamic array formulas.


For starters, is there a way to wrap the above formula in a FILTER function to filter out the "Damaged" column, and any row that doesn't contain "Yes"?

As of now I am, in another column, using this formula to filter: =FILTER(H6#,(H5:J5="Building")+(H5:J5="Deductible")) to narrow down my columns. Can I add an argument to eliminate the rows containing "Yes" in the damaged column?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
How about
Excel Formula:
=LET(NUMCols,COLUMNS(Sheet1!C6:E15),RowsA,ROWS(Sheet1!C6:E15),RowsB,ROWS(Sheet2!C6:E15),SeqCol,SEQUENCE(RowsA+RowsB),SeqRow,SEQUENCE(1,NUMCols),Result,IF(SeqCol<=RowsA,INDEX(Sheet1!C6:E15,SeqCol,SeqRow),INDEX(Sheet2!C6:E15,SeqCol-RowsA,SeqRow)),FILTER(INDEX(Result,SeqCol,{1,3}),INDEX(Result,,2)="Yes"))
 
Upvote 0
How about
Excel Formula:
=LET(NUMCols,COLUMNS(Sheet1!C6:E15),RowsA,ROWS(Sheet1!C6:E15),RowsB,ROWS(Sheet2!C6:E15),SeqCol,SEQUENCE(RowsA+RowsB),SeqRow,SEQUENCE(1,NUMCols),Result,IF(SeqCol<=RowsA,INDEX(Sheet1!C6:E15,SeqCol,SeqRow),INDEX(Sheet2!C6:E15,SeqCol-RowsA,SeqRow)),FILTER(INDEX(Result,SeqCol,{1,3}),INDEX(Result,,2)="Yes"))
Thank you, this is more than I could have hoped for.

Is there a quick way to add more sheets with the same cell ranges to this formula? I thought I could just name RowsC, add it to the SeqCol, and add another index, but I was seemingly mistaken?
 
Upvote 0
That should work, but you will need to make the IF a nested IF to account for the extra sheet.
Also do you have the VSTACK function yet?
 
Upvote 0
That should work, but you will need to make the IF a nested IF to account for the extra sheet.
Also do you have the VSTACK function yet?
Hmm, I tried to make a nested IF alongside adding a new sheet, and adjusting SeqCol, but I am getting an error.
=LET(NUMCols,COLUMNS(Sheet1!C6:E15),RowsA,ROWS(Sheet1!C6:E15),RowsB,ROWS(Sheet2!C6:E15),RowsC,ROWS(Sheet3!C6:E15),SeqCol,SEQUENCE(SUM(RowsA,RowsB,RowsC)),SeqRow,SEQUENCE(1,NUMCols),Result,IF(SeqCol<=RowsA,INDEX(Sheet1!C6:E15,SeqCol,SeqRow),IF(SeqCol<=RowsA,INDEX(Sheet2!C6:E15,SeqCol-RowsA,SeqRow),INDEX(Sheet2!C6:E15,SeqCol-RowsA,SeqRow))),FILTER(INDEX(Result,SeqCol,{1,3}),INDEX(Result,,2)="Yes"))
I would love to use VSTACK, but as of now I am not an Office Insider and my employer wouldn't sign me up. I can't wait for the new DAFs to be implemented in 365 for everyone.
 
Upvote 0
I think my main confusion with this formula is with what the IF statement is actually doing and how to add more criteria for further nested IFS. This is hard to wrap my head around at the moment.
 
Upvote 0
Ok, how about
Excel Formula:
=LET(NUMCols,COLUMNS(Sheet1!C6:E15),RowsA,ROWS(Sheet1!C6:E15),RowsB,RowsA+ROWS(Sheet2!C6:E15),RowsC,RowsB+ROWS(Sheet3!C6:E15),SeqRows,SEQUENCE(RowsC+ROWS(Sheet4!C6:E15)),SeqCols,SEQUENCE(1,NUMCols),Result,IF(SeqRows<=RowsA,Sheet1!C6:E15,IF(SeqRows<=RowsB,INDEX(Sheet2!C6:E15,SeqRows-RowsA,SeqCols),IF(SeqRows<=RowsC,INDEX(Sheet3!C6:E15,SeqRows-RowsB,SeqCols),INDEX(Sheet4!C6:E15,SeqRows-RowsC,SeqCols)))),FILTER(INDEX(Result,SeqRows,{1,3}),INDEX(Result,,2)="Yes"))
 
Upvote 0
Solution
Ok, how about
Excel Formula:
=LET(NUMCols,COLUMNS(Sheet1!C6:E15),RowsA,ROWS(Sheet1!C6:E15),RowsB,RowsA+ROWS(Sheet2!C6:E15),RowsC,RowsB+ROWS(Sheet3!C6:E15),SeqRows,SEQUENCE(RowsC+ROWS(Sheet4!C6:E15)),SeqCols,SEQUENCE(1,NUMCols),Result,IF(SeqRows<=RowsA,Sheet1!C6:E15,IF(SeqRows<=RowsB,INDEX(Sheet2!C6:E15,SeqRows-RowsA,SeqCols),IF(SeqRows<=RowsC,INDEX(Sheet3!C6:E15,SeqRows-RowsB,SeqCols),INDEX(Sheet4!C6:E15,SeqRows-RowsC,SeqCols)))),FILTER(INDEX(Result,SeqRows,{1,3}),INDEX(Result,,2)="Yes"))
I ALMOST understand... Until next time.

Now to add another 20 sheets to the formula for my actual data set..

Thank you so much for your help,
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top