Trying to include two bits of criteria from the same column in a COUNTIFS formula
I have used a variation of this formula so I can compile the total amount of stores in two particular states. I was able to exclude both NY & MA in a similar formula using the <> before {ALL STORE Rollout Schedule-IT-1547-EG Range 5}, but now that I ONLY want to include MA & NY I'm having trouble. I'm able to do one state or the other, but when I have the formula outlined like it is below then it gives me a result of zero which I know to be incorrect.
=COUNTIFS({ALL STORE Rollout Schedule-IT-1547-EG Range 1}, "Store Name", {ALL STORE Rollout Schedule-IT-1547-EG Range 4}, "Open", {ALL STORE Rollout Schedule-IT-1547-EG Range 5}, "MA", {ALL STORE Rollout Schedule-IT-1547-EG Range 5}, "NY")
Best Answer
-
@BethWork Hi Beth! In your formula above, the COUNTIFS is looking for all scenarios to be true in order to count it. So you're saying Range 5 should equal MA and it should also equal NY. IT can't equal both, so it finds zero instances of that.
You'll want to use the OR operator. So just use one reference to your Range 5, then...
OR(@cell = "MA", @cell = "NY")
=COUNTIFS({ALL STORE Rollout Schedule-IT-1547-EG Range 1}, "Store Name", {ALL STORE Rollout Schedule-IT-1547-EG Range 4}, "Open", {ALL STORE Rollout Schedule-IT-1547-EG Range 5}, OR(@cell = "MA", @cell = "NY"))
Answers
-
@BethWork Hi Beth! In your formula above, the COUNTIFS is looking for all scenarios to be true in order to count it. So you're saying Range 5 should equal MA and it should also equal NY. IT can't equal both, so it finds zero instances of that.
You'll want to use the OR operator. So just use one reference to your Range 5, then...
OR(@cell = "MA", @cell = "NY")
=COUNTIFS({ALL STORE Rollout Schedule-IT-1547-EG Range 1}, "Store Name", {ALL STORE Rollout Schedule-IT-1547-EG Range 4}, "Open", {ALL STORE Rollout Schedule-IT-1547-EG Range 5}, OR(@cell = "MA", @cell = "NY"))
-
If it's not a contact cell, which it looks like it's not per what you've provided, you probably need to use the AND and CONTAINS within your formula. I would suggest:
=COUNTIFS({ALL STORE Rollout Schedule-IT-1547-EG Range 1}, "Store Name", {ALL STORE Rollout Schedule-IT-1547-EG Range 4}, "Open", {ALL STORE Rollout Schedule-IT-1547-EG Range 5}, AND(CONTAINS("MA",@cell), CONTAINS("NY",@cell)))
-
@Ryan Sides Ah! I tried and OR statement earlier and clearly had my syntax completely wrong because I could get it to work. Yours worked perfectly. Thank you!
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 439 Global Discussions
- 138 Industry Talk
- 471 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 68 Community Job Board
- 486 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!