Loaded question with filter function multiple criteria and return value.

floW_5

New Member
Joined
Jan 4, 2024
Messages
29
Office Version
  1. 365
Platform
  1. Windows
So I have tried to make the attempt myself with whatever research info I have found online so far. Unfortunately I cant get anywhere near what I am after.
I am aware this is a loaded question and probably does not make much sense. I do appreciate any assistance If this is possible, and thank you in advance.
Sample.xlsx
ABCDEFGHIJKLMNO
1DateBevTypeInvPDSMSMidSASBeverageTypePrev. day salesMonthYear
201-Jan-24LatteCoffee503720141LatteCoffee10Jan2020
301-Nov-24CokeSoda50323156Coke30Aug2024
406-Apr-21Mount FranklinWater502520165Espresso
504-Mar-20EspressoCoffee301574Mountain Dew
612-Feb-20CappucinoCoffee3026107
726-Jul-23Pepsi Soda4011172
827-Aug-20Mountain DewSoda20731DateBevTypePDS
917-Sep-217 UpSoda20741-Jan-24LatteCoffee37
1022-Nov-23Red BullEnergy3010551-Nov-24CokeSoda32
1105-Oct-23GetaradeEnergy305194-Mar-20EspressoCoffee15
12
Sheet2
Cell Formulas
RangeFormula
J9:M11J9=FILTER(FILTER(Menu2,(Menu2[Bev]=J2)+(Menu2[Bev]=J3)+(Menu2[Bev]=J4)+(Menu2[Bev]=J5)*(Menu2[Type]=K2)*(Menu2[PDS]<=L2)*(Menu2[PDS]>=30),""),COUNTIFS(J8:M8,Menu2[#Headers]))
Dynamic array formulas.
Named Ranges
NameRefers ToCells
_FilterDatabase=Sheet2!$J$3:$N$10J9


So in this example, the new filtered down table would show, all the Beverages from (J2-J5), which includes Beverages that are "Coffee" from (K2). If (K2) is blank, return value should only show Beverages from J2-J5 that IS NOT a Coffee (only Coke & Mountain Dew would be visible in this example). If any of J2-J5 cell are empty, exclude those values from the table. So if (J3) is empty, results will only come back for J2, J4, and J5. If ALL J2-J5 are empty, results will return with "No specific data" in the new table and no data should be visible for this scenario.

Now between what is visible so far, filter it down even further and show current Beverages that is less than (L2) and greater than (L3). If (L2) is blank, than return value will only show current Beverages greater than (L3). If both L2-L3 are blank, return table will only show "No specific data" with no data shown. (typically, there will always be at least 1 value between those two cells)

Same goes for years and months, filter down to 2020 and 2024 in Jan and Aug. But If both cells are blank either from M2-M3 or N2-N3, return table to "No specific data". (Again, typically there will always be at least 1 value between (N2-N3) AND 1 value from (M2-M3), Meaning, there will always be at least ONE year and ONE month present in the assigned cells.

If there are no data that matches all specific criteria, return as "No specific data"

Going by what is shown in this sample sheet, the final table should only show Latte and Mountain Dew values.

Note: (K2) will be the only cell that can be blank. Which means if (K2) is blank, return should be all values from the other columns but EXcludes only "Coffee" type drinks. In all other cases there will ALWAYS be at least one value from the other columns (J,L,M,N). If only 1 column is fully empty from either J,L,M or N, no data should be shown at all.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Your filters aren't grouped correctly, and you've got <= and >= round the wrong way.

I think you want:

J9: =IFERROR(FILTER(FILTER(Menu2,((Menu2[Bev]=J2)+(Menu2[Bev]=J3)+(Menu2[Bev]=J4)+(Menu2[Bev]=J5))*IF(K2="Coffee",Menu2[Type]=K2,Menu2[Type]<>"Coffee")*(Menu2[PDS]>=L2)*(Menu2[PDS]<=L3)),COUNTIFS(J8:M8,Menu2[#Headers])),"No specific data")

or: =IFERROR(FILTER(FILTER(Menu2,ISNUMBER(MATCH(Menu2[Bev],J2:J5,))*IF(K2="Coffee",Menu2[Type]=K2,Menu2[Type]<>"Coffee")*(Menu2[PDS]>=L2)*(Menu2[PDS]<=L3)),COUNTIFS(J8:M8,Menu2[#Headers])),"No specific data")

For the date part, you're better off using dates than text values for the month. For example, to capture all dates from Jan 2020 to Aug 2024 inclusive, have start date 1 Jan 2020 (you can format as MMMM YYYY if you like) and end date 1 Sep 2024. Then you can add another multiplicative filter checking *(Menu2[Date]>=StartDate)*(Menu2[Date]<EndDate)
 
Upvote 0
Solution
Your filters aren't grouped correctly, and you've got <= and >= round the wrong way.

I think you want:

J9: =IFERROR(FILTER(FILTER(Menu2,((Menu2[Bev]=J2)+(Menu2[Bev]=J3)+(Menu2[Bev]=J4)+(Menu2[Bev]=J5))*IF(K2="Coffee",Menu2[Type]=K2,Menu2[Type]<>"Coffee")*(Menu2[PDS]>=L2)*(Menu2[PDS]<=L3)),COUNTIFS(J8:M8,Menu2[#Headers])),"No specific data")

or: =IFERROR(FILTER(FILTER(Menu2,ISNUMBER(MATCH(Menu2[Bev],J2:J5,))*IF(K2="Coffee",Menu2[Type]=K2,Menu2[Type]<>"Coffee")*(Menu2[PDS]>=L2)*(Menu2[PDS]<=L3)),COUNTIFS(J8:M8,Menu2[#Headers])),"No specific data")

For the date part, you're better off using dates than text values for the month. For example, to capture all dates from Jan 2020 to Aug 2024 inclusive, have start date 1 Jan 2020 (you can format as MMMM YYYY if you like) and end date 1 Sep 2024. Then you can add another multiplicative filter checking *(Menu2[Date]>=StartDate)*(Menu2[Date]
I see, the formula you provided indeed works (no error) but It is returning as no specific data, even though I input criteria that should match what's available to show. It is ok though I have found the solution on reddit and it is working for me as intended. I thank you for your time and effort though. 🙏 Thank you kindly
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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