Countif calculation based on cell values

creative999

Board Regular
Joined
Jul 7, 2021
Messages
100
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
  2. MacOS
Im trying to do a countif based on a few criteria. The existing formulae works fine (below), but i now need to add a new condition which basically says: If A1 = "small" then count DATA!D:D. If A1 = "large" then count DATA!E:E

C1=COUNTIFS(DATA!A:A,"ABC",DATA!B:B,Z1,DATA!C:C,"TESTING)
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Im trying to do a countif based on a few criteria. The existing formulae works fine (below), but i now need to add a new condition which basically says: If A1 = "small" then count DATA!D:D. If A1 = "large" then count DATA!E:E

C1=COUNTIFS(DATA!A:A,"ABC",DATA!B:B,Z1,DATA!C:C,"TESTING)
Seems to me like that should be two separate COUNTIFS functions, added together.
 
Upvote 0
I need this to be a one or the other, not both
Yes, and that is exactly what that should do.
Based on your "A1" criteria, there is no way it can be "both", so there is no risk in double-counting anything.
Have you at least tried it before discrediting it?
 
Upvote 0
Yes. Stripped the formulae back to just these two conditions and get a VALUE error:

=COUNTIFS(B4,"OPEN",DATA!G:G,D4)
+COUNTIFS(B4,"CLOSED",DATA!Z:Z,D4)
 
Upvote 0
Within each COUNTIFS formula, your various criteria ranges must be the same size (see: COUNTIFS function - Microsoft Support).
B4 is a single cell and G:G is a whole column, so they are NOT the same size.

But now I think I have a better idea of exactly what you are trying to do, and I think this is what you want:
Excel Formula:
=IF(B4="OPEN",COUNTIF(DATA!G:G,D4),0) + IF(B4="CLOSED",COUNTIF(DATA!Z:Z,D4),0)
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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