Data filters - how to use multiple filters to select rows, without adding further columns

stefanaalten

Board Regular
Joined
Feb 1, 2011
Messages
76
Office Version
  1. 365
Platform
  1. Windows
Hi,

I often find I want to use data filters to select rows based on multiple columns, but can't seem to do this without adding extra columns to artificially create the OR condition. Here's a simplified example to illustrate my question. In practice I have a spreadsheet with several thousand rows and around 30 columns each with indicators (mainly of the "Yes/No" variety)

Book1
ABCD
1ItemColourMatterColour or matter
2ABlueSolidBlue or solid
3BBlueLiquidBlue or solid
4CRedSolidBlue or solid
5DRedLiquidNeither blue nor solid
Sheet1
Cell Formulas
RangeFormula
D2:D5D2=IF(OR(B2="Blue",C2="Solid"),"Blue or solid","Neither blue nor solid")


In the example I can easily use the filters (i.e. the drop-down lists with check boxes) to create an AND style query without needing the extra column, i.e. show me rows where the item is both blue and solid. However, if I want to see rows where the item is either blue or solid (or both), I need to add a new column.

In the trivial example that's easily done, but with 30 columns the permutations multiply massively. Is there a way of using existing filters to create an OR type query?

Many thanks!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
If you want to use the built-in filter functionality, you'd need to use VBA. One way to query using formula:
Book2
ABCDEFGHI
1ItemColourMatterCriteriaItemColourMatter
2ABlueSolidRedABlueSolid
3BBlueLiquidBlueBBlueLiquid
4CRedSolidSolidCRedSolid
5DPinkSolidDPinkSolid
Sheet4
Cell Formulas
RangeFormula
G2:I5G2=FILTER(A2:C5,BYROW(A2:C5,LAMBDA(x,SUM(COUNTIFS(x,E2:E4)))))
Dynamic array formulas.
 
Upvote 0
If you want to use the built-in filter functionality, you'd need to use VBA. One way to query using formula:
Book2
ABCDEFGHI
1ItemColourMatterCriteriaItemColourMatter
2ABlueSolidRedABlueSolid
3BBlueLiquidBlueBBlueLiquid
4CRedSolidSolidCRedSolid
5DPinkSolidDPinkSolid
Sheet4
Cell Formulas
RangeFormula
G2:I5G2=FILTER(A2:C5,BYROW(A2:C5,LAMBDA(x,SUM(COUNTIFS(x,E2:E4)))))
Dynamic array formulas.
If you want to use the built-in filter functionality, you'd need to use VBA. One way to query using formula:
Book2
ABCDEFGHI
1ItemColourMatterCriteriaItemColourMatter
2ABlueSolidRedABlueSolid
3BBlueLiquidBlueBBlueLiquid
4CRedSolidSolidCRedSolid
5DPinkSolidDPinkSolid
Sheet4
Cell Formulas
RangeFormula
G2:I5G2=FILTER(A2:C5,BYROW(A2:C5,LAMBDA(x,SUM(COUNTIFS(x,E2:E4)))))
Dynamic array formulas.
Thanks Cubist, but your solution - if I understand correctly - still means adding a separate query for each possible combination. With my 30 columns and combination of multiple columns (i.e. more than just two as per my noddy example) that would become impractical. I was thinking of a way of selecting (ticking in a list) values in multiple columns and finding rows where any one of the selected values is met. Is there an Excel plugin that could do this perhaps?
 
Upvote 0
My solution checks if at least one of the columns (A,B, or C) fits at least one of the criteria in E - return that row.
 
Upvote 0

Forum statistics

Threads
1,225,730
Messages
6,186,698
Members
453,369
Latest member
positivemind

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