filter with multiple and or criteria

raaj11

New Member
Joined
Aug 4, 2024
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi i am trying to list all product and product code and quantity where location is "Melbourne" Quantity > 0 and Product_State = New + if product is in melbourne and quantity is 0 but product code exist in column "j" that should also be included in the result. i got the first part working with formula =UNIQUE(FILTER(F:H,(B:B="Melbourne")*(H:H<>"0")*(D:D="NEW"))) but could not figure out the second part to include if product is in melbourne and quantity is 0 but product code exist in column "j" that should also be included in the result.
1722837851583-png.114945
 

Attachments

  • 1722837851583.png
    1722837851583.png
    235.7 KB · Views: 79

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Try

Excel Formula:
=UNIQUE(FILTER(F:H,((B:B="Melbourne")*(H:H<>"0")*(D:D="NEW"))+((B:B="Melbourne")*(H:H=0)*(COUNTIFS(J:J,G:G)))))
 
Upvote 0
try

Excel Formula:
=UNIQUE(FILTER(HSTACK(F:F,IF(H:H=0,J:J,G:G),H:H),(B:B="Melbourne")*(D:D="NEW")))
 
Upvote 0
Try

Excel Formula:
=UNIQUE(FILTER(F:H,((B:B="Melbourne")*(H:H<>"0")*(D:D="NEW"))+((B:B="Melbourne")*(H:H=0)*(COUNTIFS(J:J,G:G)))))
hi Myall_blues
Thanks heaps for the quick reply and the formula worked for the question i asked but looking at the output i realized that i made a mistake in asking the question. lines marked yellow should not have been returned in the result.

only product we need to target from column j are the ones that are not already picked up by the base formula =UNIQUE(FILTER(F:H,(B:B="Melbourne")*(H:H<>"0")*(D:D="NEW")))

1722840688606.png
 
Upvote 0
It looks like you missed out the (H:H=0) part in the second part of the formula.
 
Upvote 0
That should fix it as the other one excludes zeroes, so it can’t be both.
 
Upvote 0
Maybe like this:

Excel Formula:
=UNIQUE(FILTER(F:H,(B:B="Melbourne")*(H:H<>"0")*((D:D="NEW")+COUNTIFS(J:J,G:G))))
 
Upvote 0
hi Myall_blues
Thanks heaps for the quick reply and the formula worked for the question i asked but looking at the output i realized that i made a mistake in asking the question. lines marked yellow should not have been returned in the result.

only product we need to target from column j are the ones that are not already picked up by the base formula =UNIQUE(FILTER(F:H,(B:B="Melbourne")*(H:H<>"0")*(D:D="NEW")))

It looks like you missed out the (H:H=0) part in the second part of the formula.
hi Mayall_blues sorry for the late reply. if i keep the H:H=0 part in then it will miss the items that appear on the fixed product list but has 0 quantity in the source array. i think i need to de a better job at defining what i am trying to achieve. expected output is to give me the stock count of each product in melbourne where quantity is > 0 + any product that is on the fixed product (column j ) but has quantity = 0. with this requirement if i keep the (H:H=0) in the or part of your formula that would filter out product that are in column j but in the source array they have quantity 0. i think i might have to work on SunnyAlv approach to first find all product codes where location is melbourne and quantity is > 0 + all product code where quantity = 0 but it exist in fixed product code (column j) then get final output to have this combined product code list vlook or filter against range F:H with only conditions of location = "melbourne" and productstate = "new"

1722980966494.png
 
Upvote 0
Did you actually try it before you reached these conclusions?

In your original post you wanted:
where location is "Melbourne" Quantity > 0 and Product_State = New
The first clause in the FILTER formula ((B:B="Melbourne")*(H:H<>"0")*(D:D="NEW")) gives all those results.
You also wanted:
if product is in melbourne and quantity is 0 but product code exist in column "j"
The second clause in the FILTER formula ((B:B="Melbourne")*(H:H=0)*(COUNTIFS(J:J,G:G)) gives all those results (noting you asked for quantity is 0).

The '+' sign (shown in red below) between those two clauses means either the results of the first clause OR the results of the second clause can be included in the output (i.e it is a conditional OR, not a conditional AND).
=UNIQUE(FILTER(F:H,((B:B="Melbourne")*(H:H<>"0")*(D:D="NEW"))[B][SIZE=6][COLOR=rgb(184, 49, 47)]+[/COLOR][/SIZE][/B]((B:B="Melbourne")*(H:H=0)*(COUNTIFS(J:J,G:G)))))
 
Upvote 0
Solution
Did you actually try it before you reached these conclusions?

In your original post you wanted:

The first clause in the FILTER formula ((B:B="Melbourne")*(H:H<>"0")*(D:D="NEW")) gives all those results.
You also wanted:

The second clause in the FILTER formula ((B:B="Melbourne")*(H:H=0)*(COUNTIFS(J:J,G:G)) gives all those results (noting you asked for quantity is 0).

The '+' sign (shown in red below) between those two clauses means either the results of the first clause OR the results of the second clause can be included in the output (i.e it is a conditional OR, not a conditional AND).
=UNIQUE(FILTER(F:H,((B:B="Melbourne")*(H:H<>"0")*(D:D="NEW"))[B][SIZE=6][COLOR=rgb(184, 49, 47)]+[/COLOR][/SIZE][/B]((B:B="Melbourne")*(H:H=0)*(COUNTIFS(J:J,G:G)))))
Hi Murray
thanks heaps and sorry for my slow understanding. i have the desired output now.

1722995100682.png
 
Upvote 0

Forum statistics

Threads
1,223,270
Messages
6,171,102
Members
452,379
Latest member
IainTru

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