Using Countifs formula with And/Or operator (?)

Lambrix

Board Regular
Joined
Jun 29, 2012
Messages
62
I am stuck on how to make a formula that would count how many people in Section B telework on the First Monday of the pay period. The Telework data is in 4 different columns. I am stuck on using the And/Or operators. Any ideas?

Countifs(C:C,"Section B") And countifs(F:F, "Monday P1") or countifs(G:G, "Monday P1") or countifs(H:H, "Monday P1) or countifs(I:I, "Monday P1")

Any ideas?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Does this get it for you?
=SUMPRODUCT(--(B2:B100="Section B")*--(F2:I100="Monday P1"))
 
Upvote 0
Hi Lambrix

A question:

What happens if you have more that one match in the same row, for ex. Columns F and H. Do you want to count that row as 2 or as 1?
 
Upvote 0
Hi Lambrix

A question:

What happens if you have more that one match in the same row, for ex. Columns F and H. Do you want to count that row as 2 or as 1?

Just as a one. But there shouldn't be any matches within the same row of information because each row represents a single employee which can't work the same telework day more than once.

Any ideas?
 
Upvote 0
hmmm . . . works for me. Using the following, the formula correctly counts 4 instances where column B contains "Section B" and "Monday P1" is found in the same row in columns F, G, H or I

A</SPAN>
B</SPAN>
C</SPAN>
D</SPAN>
E</SPAN>
F</SPAN>
G</SPAN>
H</SPAN>
I</SPAN>
2</SPAN>
Monday P1</SPAN>
3</SPAN>
Section B</SPAN>
Monday P1</SPAN>
4</SPAN>
Monday P1
5</SPAN>
Section B</SPAN>
Monday P1</SPAN>
6</SPAN>
Section A
Monday P1
7</SPAN>
Section B</SPAN>
Monday P1</SPAN>
8</SPAN>
Section B</SPAN>
Monday P1</SPAN>
9</SPAN>
10</SPAN>
4</SPAN>
11</SPAN>
Cell C10 formula: =SUMPRODUCT(--(B2:B100="Section B")*--(F2:I100="Monday P1"))</SPAN>

<TBODY>
</TBODY>
 
Last edited:
Upvote 0
Okay, so I have been trying to expand on your formula by adding one more criteria range and criteria. The Criteria range would be A2:A100 and the Criteria would be, "DC"

Here is the adjustment that I have made to the formula which is not working:
C10 formula: =SUMPRODUCT(--(B2:B100="Section B")*--(F2:I100="Monday P1")*--(A2:A100="DC"))

Any ideas?
 
Upvote 0
Your revised formula works for me (when I added DC to some cells in Col A ;))

i.e. Leaving table exactly the way it was, but adding DC in A3 and A5, the formula returns 2, which is the right answer.

Hint: If you have "DC " (DC space) either in the formula or the cell, you won't have a match.

Have you ever used Formulas|Formula Auditing|Evaluate Formula to walk through a formula step by step? This is really a good way to see exactly how a formula works (and where you've gone right or wrong!) In this example, I'd narrow your formula down to rows 1-8 before stepping through it and then once you understand what the formula is doing and you have it working right, you can expand the range in your formula to be what you need.
 
Upvote 0

Forum statistics

Threads
1,217,366
Messages
6,136,128
Members
449,993
Latest member
Sphere2215

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