Two-way Filter in Google Sheets: Unlocking Dynamic Vertical and Horizontal Filtering

Have you ever heard of the two-way filter in Google Sheets? It’s a powerful tool that allows you to extract rows and columns based on specific criteria. Think of it as a dynamic horizontal and vertical filter that takes your data analysis to the next level. Surprisingly, not many tutorials or tips have covered this feature in Google Sheets or Excel. So if you’re new to the concept, don’t worry, I’ve got you covered!

To perform a two-way filter in Google Sheets, you can use a combination of functions like MATCH and Query. These functions work together to conditionally filter both rows and columns, all in a single formula. In this article, I’ll walk you through the step-by-step process of utilizing this powerful feature.

The Magic Behind the Two-way Filter in Google Sheets

dynamic two-way filter in Google Sheets

Let’s dive into an example to help you understand how this works. Imagine you have a spreadsheet with various data, and you want to filter rows that contain the name “Betty” and columns that represent the subject “Chemistry.” By applying the two-way filter formula, you can easily extract the relevant data.

The formula for this specific case would look like this:

=query({$A$3:$F},"Select Col1,Col2,Col"&match($H$6,$A$3:$F$3,0)&" where Col1='"&H4&"'")

Let’s break down the formula:

  • {$A$3:$F}: This represents the data range in which you want to apply the filter.
  • Select Col1,Col2,: These are the static columns that contain the Name and Exam information.
  • match($H$6,$A$3:$F$3,0): This matches the criterion specified in cell H6 with the values in the first row of the data range.
  • where Col1='"&H4&"'"): This filters the rows based on the criterion specified in cell H4.

Easy, right? You can modify the formula by adding or changing the filter conditions to suit your specific data range and criteria.

Enhancing the Two-way Filter: Adding More Conditions

What if you want to apply multiple conditions to the row filtering? No problem! Let’s expand on our previous example and add an additional condition. We’ll now filter rows based on two criteria and columns based on one criterion.

two-way filter - 2 conditions

Here’s the formula for this enhanced version:

=query({$A$2:$G},"Select Col1,Col2,Col"&match($J$3,$A$2:$G$2,0)&" where Col1='"&I3&"' or Col1='"&I4&"'")

In this case, we’ve expanded the data range to include another column (column G), and the MATCH function adjusts accordingly. You can see the OR operator in the query formula, allowing multiple filtering conditions.

Unleashing the Power of Two-way Filter: Filtering Multiple Columns

Filtering rows based on multiple conditions is relatively straightforward with the Query function. However, filtering columns poses a different challenge. But fear not, I have a technique for you!

To filter multiple columns, use the TEXTJOIN and ArrayFormula functions in conjunction with MATCH. This combination allows you to dynamically filter two or more columns.

two-way filter - 2 columns

Here’s the formula to filter two columns:

=query({$A$2:$G},"Select Col1,Col2,Col"&textjoin(",Col",true,ArrayFormula(match($J$3:$J$4,$A$2:$G$2,0)))&" where Col1='"&I3&"' or Col1='"&I4&"'")

Notice how the MATCH function now uses a range of criteria (J3:J4) and matches them against the values in the first row of the data range (A2:G2). By adjusting the range in the MATCH function, you can easily include additional columns in your filtering.

Conclusion: Unveiling the Secrets of Two-way Filter in Google Sheets

And there you have it! You now possess the knowledge to unlock the full potential of the two-way filter in Google Sheets. This dynamic feature empowers you to filter data both vertically and horizontally using a single formula. It opens up possibilities for advanced data analysis, enabling you to make better-informed decisions.

If you want to explore more handy tips and tricks for mastering Google Sheets, head on over to Crawlan.com. You’ll find a wealth of resources to further enhance your spreadsheet skills. Happy filtering!

Related posts