Filter formula with more than 1 criteria

floggingmolly

Board Regular
Joined
Sep 14, 2019
Messages
167
Office Version
  1. 365
Platform
  1. Windows
I'm trying to use a filter formula using 1 of 2 criteria, or both depending on what the user selects. In cell B2 they can select a district, and in H2 then can select a station. I want the data to filter depending on what they choose. It's working if they select 1 criteria, for example if they choose a district in B2 then the data filters to that district. If they choose a Station in H2 the data filters to that station. But if they choose a district and a station, it only filters the district and still shows all stations for that district. Is there a way to make it filter by both criteria if they are both entered? I've tried for 2 days but can't get it. Any help would be appreciated. I'm not even sure if the Filter function can do this but thought I'd give it a shot. Here is the formula I'm using: =FILTER(ALL_DATA,((ALL_DATA[District]=B2) * (ALL_DATA[Station]=H2)) + ((ALL_DATA[District]=B2) + (ALL_DATA[Station]=H2)),"")
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
How about
Excel Formula:
=FILTER(ALL_DATA,(IF(B2="",1,ALL_DATA[District]=B2))*(IF(H2="",1,ALL_DATA[Station]=H2)))
 
Upvote 0
How about
Excel Formula:
=FILTER(ALL_DATA,(IF(B2="",1,ALL_DATA[District]=B2))*(IF(H2="",1,ALL_DATA[Station]=H2)))
I think this will work. Is there a way to hide the #VALUE! error if both cells are blank? I tried using the ,"" but the error is still visible.
 
Upvote 0
How about
Excel Formula:
=IF(AND(B2="",H2=""),"",FILTER(All_Data,(IF(B2="",1,All_Data[District]=B2))*(IF(H2="",1,All_Data[Station]=H2))))
 
Upvote 0
I think this will work. Is there a way to hide the #VALUE! error if both cells are blank? I tried using the ,"" but the error is still visible.
I got it, using IFERROR. The formula you provided works perfect. Thank you so much for your help and the quick response. Much appreciated. Have a great day.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
In this instance, It just signifies True.
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

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