CountIF AND Help

KuraiChikara

Board Regular
Joined
Nov 16, 2016
Messages
111
Office Version
  1. 2013
Platform
  1. Windows
Hello, I am trying to perform a Countif or a Countifs AND function and I'm having issues.
I have success with IF AND functions but can't seem to get COUNTIF AND functions to work.

Working Shift Examples:
Employees can have 7 combinations of days off formatted:
F--MTWR
--SMTWR
FY--TWR
FYS--WR
FYSM--R
FYSMT--
-YSMTW-

<tbody>
</tbody>



In the example below I would want to figure out "who comes in on Monday at 6:30 AM?"

There are 9 week types and 2 of those types have people that don't come in Monday at all (Sun/Mon off or Mon/Tues off in asterisk) which would mean 7 agents come in at 6:30 AM on Monday but I can't set that up in a formula.

I've tried the following:
=COUNTIF(AND(B1=C1,B1=C2,B1=C3,B1=C4,B1=C5,B1=C6,B1=C7)B1:B10,C1))
(and simply nest the formula for the 6 other day of the week types. If the formula worked shown above, I was looking at the Sat/Sun off people and there are 4 of them, if I nest it I can include all the other week types that exclude agents who don't come in on Monday which totals 7).

The issue I have with the COUNTIFAND function is after the AND function parenthesis:
C7)B1:B10,C1)) where the parenthesis ends on C7 and the B1 begins I need a COMMA to go into the range portion of the COUNTIF, but when I add the comma, it jumps immediately to criteria.



TimeWeekCriteria
6:30 AMF--MTWRF--MTWR
6:30 AM--SMTWR--SMTWR
6:30 AMFY--TWRFY--TWR***
6:30 AMFYS--WRFYS--WR***
6:30 AMFYSM--RFYSM--R
6:30 AMFYSMT--FYSMT--
6:30 AM-YSMTW--YSMTW-
6:30 AMF--MTWR
6:30 AMF--MTWR

<tbody>
</tbody>
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
You're a genius buddy, Excel has a million ways to skin a cat and I simply didnt know that method. I actually fixed my issue and created a more complex formula but I had to include information like day off abbreviations. Sa, Su, Mo, Tu, etc.
The data below, like the grid above with days off instead of week and criteria. I used this formula to calculate the same thing.

=COUNTIFS($B$37:$B$43,"SA",$C$37:$C$43,"SU",$A$37:$A$43,A37)+COUNTIFS($B$37:$B$43,"SU",$C$37:$C$43,"MO",$A$37:$A$43,A37)+COUNTIFS($B$37:$B$43,"MO",$C$37:$C$43,"TU",$A$37:$A$43,A37)+COUNTIFS($B$37:$B$43,"TU",$C$37:$C$43,"WE",$A$37:$A$43,A37)+COUNTIFS($B$37:$B$43,"WE",$C$37:$C$43,"TH",$A$37:$A$43,A37)+COUNTIFS($B$37:$B$43,"TH",$C$37:$C$43,"FR",$A$37:$A$43,A37)+COUNTIFS($B$37:$B$43,"FR",$C$37:$C$43,"SA",$A$37:$A$43,A37)

StartDay OffDay Off
6:30 AMSaSu
6:30 AMSuMo
6:30 AMMoTu
6:30 AMTuWe
6:30 AMWeTh
6:30 AMThFr
6:30 AMFrSa

<colgroup><col span="2"><col></colgroup><tbody>
</tbody>
 
Upvote 0
Well, I'm glad you sussed it out.

A couple of thoughts. First, if the days off are always together, as they seem to be, then you don't need to check column C, because it already depends on column B, which you're checking. Second, there is a shortcut way to add a bunch of COUNTIFS like you're doing. Say you want to count everyone who comes in on Monday, then this should work:

=SUM(COUNTIFS($B$37:$B$43,{"Sa","Tu","We","Th","Fr"},$A$37:$A$43,A37))

I left out Su and Mo from the array since those two groups have Mondays in them.

Anyway, good luck!
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,732
Members
449,093
Latest member
Mnur

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