FILTER Function - Maintaining subheadings without #SPILL

MurdochQuill

Board Regular
Joined
Nov 21, 2020
Messages
84
Office Version
  1. 365
Platform
  1. Windows
Hi,

To begin with, I'm stuck using cell formulas due to Excel Online.... & I would ideally like this to be recalculated when formulas are recalculated.

I'm looking to format my data below like it is under "Ideal output"

I would like to avoid spill errors if I find more ID matches, and push the subheadings further down the page when more results are encountered.

The sheet looks like this,
Book1
ABCDEFGHIJKLMNOPQR
1INPUT DATAInitial formatIdeal output
2IDDataTerrestrial?Desert?Rocky?Gas?Terrestrial:Terrestrial:YES
3Earth3425YESNONONOEarth3425
4Mars456NOYESNONODesert:Earth345
5Jupiter325NONONOYESDesert:
6Jupiter245326NONONOYESRocky:Mars456
7Mars567NOYESNONOMars567
8Mercury3415NONONONOGas:Mars43
9Pluto456NONOYESNORocky:
10Pluto4652NONOYESNOPluto456
11Earth345YESNONONOPluto4652
12Mars43NOYESNONOGas:
13Jupiter325
14Jupiter245326
Sheet1
Cell Formulas
RangeFormula
E3:E12E3=IF(SUM((B4:B13<>"")*(ISNUMBER(MATCH("Earth",B3,0)))), "YES", "NO")
F3:F12F3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Mars",$B3,0)))), "YES", "NO")
G3:G12G3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Pluto",$B3,0)))), "YES", "NO")
H3:H12H3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Jupiter",$B3,0)))), "YES", "NO")
N3:O4N3=IFERROR(FILTER(B3:C12,ISNUMBER(MATCH(E3:E12,R2,0))),"")
N6:O8N6=IFERROR(FILTER(B3:C12,ISNUMBER(MATCH(F3:F12,R2,0))),"")
N10:O11N10=IFERROR(FILTER(B3:C12,ISNUMBER(MATCH(G3:G12,R2,0))),"")
N13:O14N13=IFERROR(FILTER(B3:C12,ISNUMBER(MATCH(H3:H12,R2,0))),"")
Dynamic array formulas.



But for example, if anything more is added, the following would give a SPILL error. However, I would like it to push the column further down like this:
Book1
ABCDEFGHIJKLMNOPQRS
1INPUT DATAInitial formatIdeal output
2IDDataTerrestrial?Desert?Rocky?Gas?Terrestrial:Terrestrial:YES
3Earth3425YESNONONOEarth3425
4Mars456NOYESNONODesert:Earth345
5Jupiter325NONONOYESDesert:
6Jupiter245326NONONOYESRocky:Mars456
7Mars567NOYESNONOMars567
8Mercury3415NONONONOGas:Mars43
9Pluto456NONOYESNOMars12
10Pluto4652NONOYESNOMars123
11Earth345YESNONONOMars124
12Mars43NOYESNONOMars125
13Mars126
14Mars127
15Mars128
16Mars129
17Mars130
18Mars131
19Mars132
20Mars133
21Rocky:
22Pluto456
23Pluto4652
24Gas:
25Jupiter325
26Jupiter245326
27
28
Sheet1
Cell Formulas
RangeFormula
E3:E12E3=IF(SUM((B4:B13<>"")*(ISNUMBER(MATCH("Earth",B3,0)))), "YES", "NO")
F3:F12F3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Mars",$B3,0)))), "YES", "NO")
G3:G12G3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Pluto",$B3,0)))), "YES", "NO")
H3:H12H3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Jupiter",$B3,0)))), "YES", "NO")
N3:O4N3=IFERROR(FILTER(B3:C12,ISNUMBER(MATCH(E3:E12,R2,0))),"")
N6:O8N6=IFERROR(FILTER(B3:C12,ISNUMBER(MATCH(F3:F12,R2,0))),"")
N22:O23N22=IFERROR(FILTER(B3:C12,ISNUMBER(MATCH(G3:G12,R2,0))),"")
N25:O26N25=IFERROR(FILTER(B3:C12,ISNUMBER(MATCH(H3:H12,R2,0))),"")
Dynamic array formulas.


Any help or advice on how else to solve this would be great!
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Why not just put them next to each other, it would be a lot simpler.
 
Upvote 0
Why not just put them next to each other, it would be a lot simpler.
As in each subheading to a row? If that's the case, it's mainly because I could have over 100 matches, and the full data set needs to carry over more columns as it's scaled up.

I've sort of boxed myself into using columns for this, but im pessimistic that there's a neat way with formulas to shift it down.

However, If it's possible by using a hidden worker page, that could be doable too. I'm just not sure how to break it up for that formatting.
 
Upvote 0
I was thinking like
+Fluff 1.xlsm
ABCDEFGHIJKLMNOPQRSTUVWX
1INPUT DATAInitial formatIdeal output
2IDDataTerrestrial?Desert?Rocky?Gas?Terrestrial:YESTerrestrial:Desert:Rocky:Gas:
3Earth3425YESNONONOEarth3425Mars456Pluto456Jupiter325
4Mars456NOYESNONODesert:Earth345Mars567Pluto4652Jupiter245326
5Jupiter325NONONOYESMars43
6Jupiter245326NONONOYESRocky:
7Mars567NOYESNONO
8Mercury3415NONONONOGas:
9Pluto456NONOYESNO
10Pluto4652NONOYESNO
11Earth345YESNONONO
12Mars43NOYESNONO
List
Cell Formulas
RangeFormula
E3:E12E3=IF(SUM((B4:B13<>"")*(ISNUMBER(MATCH("Earth",B3,0)))), "YES", "NO")
F3:F12F3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Mars",$B3,0)))), "YES", "NO")
G3:G12G3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Pluto",$B3,0)))), "YES", "NO")
H3:H12H3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Jupiter",$B3,0)))), "YES", "NO")
N3:O4N3=FILTER(B3:C12,ISNUMBER(MATCH(E3:E12,L2,0)),"")
Q3:R5Q3=IFERROR(FILTER(B3:C12,ISNUMBER(MATCH(F3:F12,L2,0))),"")
T3:U4T3=IFERROR(FILTER(B3:C12,ISNUMBER(MATCH(G3:G12,L2,0))),"")
W3:X4W3=IFERROR(FILTER(B3:C12,ISNUMBER(MATCH(H3:H12,L2,0))),"")
Dynamic array formulas.
 
Upvote 0
I was thinking like
+Fluff 1.xlsm
ABCDEFGHIJKLMNOPQRSTUVWX
1INPUT DATAInitial formatIdeal output
2IDDataTerrestrial?Desert?Rocky?Gas?Terrestrial:YESTerrestrial:Desert:Rocky:Gas:
3Earth3425YESNONONOEarth3425Mars456Pluto456Jupiter325
4Mars456NOYESNONODesert:Earth345Mars567Pluto4652Jupiter245326
5Jupiter325NONONOYESMars43
6Jupiter245326NONONOYESRocky:
7Mars567NOYESNONO
8Mercury3415NONONONOGas:
9Pluto456NONOYESNO
10Pluto4652NONOYESNO
11Earth345YESNONONO
12Mars43NOYESNONO
List
Cell Formulas
RangeFormula
E3:E12E3=IF(SUM((B4:B13<>"")*(ISNUMBER(MATCH("Earth",B3,0)))), "YES", "NO")
F3:F12F3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Mars",$B3,0)))), "YES", "NO")
G3:G12G3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Pluto",$B3,0)))), "YES", "NO")
H3:H12H3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Jupiter",$B3,0)))), "YES", "NO")
N3:O4N3=FILTER(B3:C12,ISNUMBER(MATCH(E3:E12,L2,0)),"")
Q3:R5Q3=IFERROR(FILTER(B3:C12,ISNUMBER(MATCH(F3:F12,L2,0))),"")
T3:U4T3=IFERROR(FILTER(B3:C12,ISNUMBER(MATCH(G3:G12,L2,0))),"")
W3:X4W3=IFERROR(FILTER(B3:C12,ISNUMBER(MATCH(H3:H12,L2,0))),"")
Dynamic array formulas.
Ah yes, I see what you mean. It's probably deceptive since my example only had little variation in the planet types.

In the scaled up workbook I have about 70 listed so far which each need to carry over a bunch of columns each. The above would result in quite a wide worksheet, however it could be used as a worker page to join them all together vertically. Might run a little slow but that's all I can think of at the moment...
 
Upvote 0
It's possible to do what you want, but you will loose the format of the headers.
 
Upvote 0
Does this need to work with Excel online, or just on a Windows PC?
 
Upvote 0
This formula is really awkward (and would benefit from LET), but it works:

Book1
ABCDEFGHIJKLMNOP
1INPUT DATAInitial formatIdeal output
2IDDataTerrestrial:Desert:Rocky:Gas:Terrestrial:Terrestrial:1
3Earth3425YESNONONOEarth34251
4Mars456NOYESNONODesert:Earth3451
5Jupiter325NONONOYESDesert:2
6Jupiter245326NONONOYESRocky:Mars5672
7Mars567NOYESNONOMars4562
8Mercury3415NoNOYesNOGas:Mars432
9Pluto456NONOYESNORocky:3
10Pluto4652NONOYESNOPluto46523
11Earth345YESNONONOMercury34153
12Mars43NOYESNONOPluto4563
13Gas:4
14Jupiter2453264
15Jupiter3254
16
Sheet2
Cell Formulas
RangeFormula
N2:P15N2=SORT(CHOOSE({1,2,3},IFERROR(INDEX(B3:B15,EXP(LN(SEQUENCE(COUNTA(B3:B15)+COLUMNS(E2:H2),,1-COLUMNS(E2:H2))))),INDEX(E2:H2,SEQUENCE(COLUMNS(E2:H2)))),IFERROR(INDEX(C3:C15,EXP(LN(SEQUENCE(COUNTA(B3:B15)+COLUMNS(E2:H2),,1-COLUMNS(E2:H2))))),""),IFERROR(INDEX(MMULT(--(E3:H15="YES"),SEQUENCE(COLUMNS(E2:H2))),EXP(LN(SEQUENCE(COUNTA(B3:B15)+COLUMNS(E2:H2),,1-COLUMNS(E2:H2))))),SEQUENCE(COLUMNS(E2:H2)))),{3,2},{1,-1})
E3:E7,E9:E12E3=IF(SUM((B4:B13<>"")*(ISNUMBER(MATCH("Earth",B3,0)))), "YES", "NO")
G3:G7,G9:G12G3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Pluto",$B3,0)))), "YES", "NO")
F3:F12F3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Mars",$B3,0)))), "YES", "NO")
H3:H12H3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Jupiter",$B3,0)))), "YES", "NO")
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
N:NCell Valuecontains ":"textNO


There are a few assumptions. There must be exactly one YES per row of data. If not, the results may be skewed. Column P is a helper column needed in the formula, you can hide it if you want. The bold and underline of the headings is done with Conditional Formatting.


It also occurs to me that if you change your data structure, you can come up with something much simpler. Consider:

Book1
ABCDEFGH
1INPUT DATAIdeal output
2IDDataTypeMars567Desert
3Earth3425TerrestrialMars456Desert
4Mars456DesertMars43Desert
5Jupiter325GasJupiter245326Gas
6Jupiter245326GasJupiter325Gas
7Mars567DesertPluto4652Rocky
8Mercury3415RockyMercury3415Rocky
9Pluto456RockyPluto456Rocky
10Pluto4652RockyEarth3425Terrestrial
11Earth345TerrestrialEarth345Terrestrial
12Mars43Desert
13
Sheet3
Cell Formulas
RangeFormula
F2:H11F2=SORT(INDEX(B3:D20,SEQUENCE(COUNTA(B3:B20)),{1,2,3}),{3,2},{1,-1})
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
F1:F15Cell Valuecontains ":"textNO


No headings, but it's a much simpler formula, and every planet is grouped and identified.
 
Upvote 0
This was my idea, but only works on a PC
+Fluff 1.xlsm
ABCDEFGHIJKLMNOPQR
1INPUT DATAInitial formatIdeal output
2IDDataTerrestrial?Desert?Rocky?Gas?Terrestrial:Terrestrial:YES
3Earth3425YESNONONOEarth3425
4Mars456NOYESNONODesert:Earth345
5Jupiter325NONONOYES
6Jupiter245326NONONOYESRocky:Desert:
7Mars567NOYESNONOMars456
8Mercury3415NONONONOGas:Mars567
9Pluto456NONOYESNOMars43
10Pluto4652NONOYESNO
11Earth345YESNONONORocky:
12Mars43NOYESNONOPluto456
13Pluto4652
14
15Gas:
16Jupiter325
17Jupiter245326
18
19
List
Cell Formulas
RangeFormula
N2:O17N2=LET(Ter,FILTER(B3:C12,ISNUMBER(MATCH(E3:E12,R2,0)),""),Des,FILTER(B3:C12,ISNUMBER(MATCH(F3:F12,R2,0)),""),Roc,FILTER(B3:C12,ISNUMBER(MATCH(G3:G12,R2,0)),""),Gas,FILTER(B3:C12,ISNUMBER(MATCH(H3:H12,R2,0)),""),Ary,FILTERXML("<k><m>"&TEXTJOIN("</m><m>",0,J2,"",Ter,"","",J4,"",Des,"","",J6,"",Roc,"","",J8,"",Gas)&"</m></k>","//m"),IFERROR(INDEX(Ary,SEQUENCE(ROWS(Ary)/2,,0,2)+{1,2}),""))
E3:E12E3=IF(SUM((B4:B13<>"")*(ISNUMBER(MATCH("Earth",B3,0)))), "YES", "NO")
F3:F12F3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Mars",$B3,0)))), "YES", "NO")
G3:G12G3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Pluto",$B3,0)))), "YES", "NO")
H3:H12H3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Jupiter",$B3,0)))), "YES", "NO")
Dynamic array formulas.
 
Upvote 0
This formula is really awkward (and would benefit from LET), but it works:

Book1
ABCDEFGHIJKLMNOP
1INPUT DATAInitial formatIdeal output
2IDDataTerrestrial:Desert:Rocky:Gas:Terrestrial:Terrestrial:1
3Earth3425YESNONONOEarth34251
4Mars456NOYESNONODesert:Earth3451
5Jupiter325NONONOYESDesert:2
6Jupiter245326NONONOYESRocky:Mars5672
7Mars567NOYESNONOMars4562
8Mercury3415NoNOYesNOGas:Mars432
9Pluto456NONOYESNORocky:3
10Pluto4652NONOYESNOPluto46523
11Earth345YESNONONOMercury34153
12Mars43NOYESNONOPluto4563
13Gas:4
14Jupiter2453264
15Jupiter3254
16
Sheet2
Cell Formulas
RangeFormula
N2:P15N2=SORT(CHOOSE({1,2,3},IFERROR(INDEX(B3:B15,EXP(LN(SEQUENCE(COUNTA(B3:B15)+COLUMNS(E2:H2),,1-COLUMNS(E2:H2))))),INDEX(E2:H2,SEQUENCE(COLUMNS(E2:H2)))),IFERROR(INDEX(C3:C15,EXP(LN(SEQUENCE(COUNTA(B3:B15)+COLUMNS(E2:H2),,1-COLUMNS(E2:H2))))),""),IFERROR(INDEX(MMULT(--(E3:H15="YES"),SEQUENCE(COLUMNS(E2:H2))),EXP(LN(SEQUENCE(COUNTA(B3:B15)+COLUMNS(E2:H2),,1-COLUMNS(E2:H2))))),SEQUENCE(COLUMNS(E2:H2)))),{3,2},{1,-1})
E3:E7,E9:E12E3=IF(SUM((B4:B13<>"")*(ISNUMBER(MATCH("Earth",B3,0)))), "YES", "NO")
G3:G7,G9:G12G3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Pluto",$B3,0)))), "YES", "NO")
F3:F12F3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Mars",$B3,0)))), "YES", "NO")
H3:H12H3=IF(SUM(($B3:$B12<>"")*(ISNUMBER(MATCH("Jupiter",$B3,0)))), "YES", "NO")
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
N:NCell Valuecontains ":"textNO


There are a few assumptions. There must be exactly one YES per row of data. If not, the results may be skewed. Column P is a helper column needed in the formula, you can hide it if you want. The bold and underline of the headings is done with Conditional Formatting.


It also occurs to me that if you change your data structure, you can come up with something much simpler. Consider:

Book1
ABCDEFGH
1INPUT DATAIdeal output
2IDDataTypeMars567Desert
3Earth3425TerrestrialMars456Desert
4Mars456DesertMars43Desert
5Jupiter325GasJupiter245326Gas
6Jupiter245326GasJupiter325Gas
7Mars567DesertPluto4652Rocky
8Mercury3415RockyMercury3415Rocky
9Pluto456RockyPluto456Rocky
10Pluto4652RockyEarth3425Terrestrial
11Earth345TerrestrialEarth345Terrestrial
12Mars43Desert
13
Sheet3
Cell Formulas
RangeFormula
F2:H11F2=SORT(INDEX(B3:D20,SEQUENCE(COUNTA(B3:B20)),{1,2,3}),{3,2},{1,-1})
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
F1:F15Cell Valuecontains ":"textNO


No headings, but it's a much simpler formula, and every planet is grouped and identified.
Hi, thanks for the suggestion, this was actually really useful in another workbook I have! Was after a workaround like this for a while. This is a good idea with the column determining planet type.

Does this need to work with Excel online, or just on a Windows PC?
Sorry for the late reply,

Unfortunately needs to be on Excel online... What part of that formula doesn't like Excel Online if you don't mind me asking? I'm fine without formatting, it should be ok to add back in with conditional formatting as the headers stay the same as per Eric's post.

This might deviate a little from OP, but this is how it might achieve the goal in a slightly different way based off of Eric's post on adding the type in another column should be workable. I have a large sheet already with many orders, and many variations on planet types inside as a table to look up. If I were to add the planet type next to the original data, it would have to match the "ORDER CODE". Here is an example of the lookup table on Sheet 2:

Book1
ABCDEFGHIJKL
1ORDER CODE 1ORDER 1ORDER CODE 2ORDER 2ORDER CODE 3ORDER 3ORDER CODE 4ORDER 4ORDER CODE 5ORDER 5ORDER CODE 6 ORDER 6
2
3XXXTTerrestrial 1EEEGDesert 2OOO4Rock 45JHH7Gas 354LKKK56Chthonian 54NBV2ICE546
4XXXETerrestrial 32EEEQDesert 3OOO5Rock 46JHH8Gas 355LKKK57Chthonian 55NBV3ICE547
5XXXFTerrestrial 33EEEHDesert 4OOO6Rock 47JHH9Gas 356LKKK58Chthonian 56NBV4ICE548
6XXXFTerrestrial 34EEE2Desert 5OOO7Rock 48JHH10Gas 357LKKK59Chthonian 57NBV5ICE549
7EEE6Desert 6OOO8Rock 49JHH11Gas 358LKKK60Chthonian 58NBV6ICE550
8EEE8Desert 7OOO9Rock 50JHH12Gas 359
9EEE1Desert 8OOO10Rock 51JHH13Gas 360
10EEE7Desert 9OOO11Rock 52
11OOO12Rock 53
12OOO13Rock 54
13
14
15
Sheet2



This is how the original sheet will sort of look. Col C can be added to the original data as an identifier, as my raw data output includes this code on each row which is handy.

Col E (in blue) is where I would like to do a lookup on the code table and Xlookup/Vlookup/match the ORDER name to the ORDER CODE (whichever is fastest I guess). This is the part I'm unsure how to work the formula on, and any help with the formula to get the type name would be excellent.


Book1
BCDEFGHIJ
1INPUT DATA
2IDORDER DATADataTypeORDER 1ORDER 2ORDER 3ORDER 4
3Earth467XXXF3425Terrestrial 33YESNONONO
4Mars547EEEG456Desert 2NOYESNONO
5Jupiter675JHH7325Gas 354NONONOYES
6Jupiter567JHH9245326Gas 356NONONOYES
7Mars678EEEH567Desert 4NOYESNONO
8MercuryOOO44363415Rock 45NONOYESNO
9PlutoOOO536456Rock 46NONOYESNO
10PlutoOOO65464652Rock 47NONOYESNO
11EarthXXXE3456345Terrestrial 32YESNONONO
12MarsEEE7345643Desert 9NOYESNONO
Sheet1
Cell Formulas
RangeFormula
G3:G12G3=IF(SUM((Sheet2!$A$3:$A$15<>"")*(ISNUMBER(MATCH("*"&Sheet2!$A$3:$A$15&"*",$C3,0)))), "YES", "NO")
H3:H12H3=IF(SUM((Sheet2!$C$3:$C$15<>"")*(ISNUMBER(MATCH("*"&Sheet2!$C$3:$C$15&"*",$C3,0)))), "YES", "NO")
I3:I12I3=IF(SUM((Sheet2!$E$3:$E$15<>"")*(ISNUMBER(MATCH("*"&Sheet2!$E$3:$E$15&"*",$C3,0)))), "YES", "NO")
J3:J12J3=IF(SUM((Sheet2!$G$3:$G$15<>"")*(ISNUMBER(MATCH("*"&Sheet2!$G$3:$G$15&"*",$C3,0)))), "YES", "NO")
 
Upvote 0

Forum statistics

Threads
1,215,237
Messages
6,123,811
Members
449,127
Latest member
Cyko

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