Countifs formula produces zero value with multiple criteria

ls3009

New Member
Joined
Jul 21, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Just like it says on the tin! I am trying to produce a table (below) that shows the number of employees in each department depending their start date and leaving date (leaving date is blank if they are still an employee)

1689932129115.png


This is my formula: =COUNTIFS(Summary!$F:$F,KPIs!$B33,Summary!$G:$G,"<="&D29,Summary!$H:$H,"")+COUNTIFS(Summary!$F:$F,KPIs!$B33,Summary!$G:$G,"<="&D29,Summary!$H:$H,">="&D30)

This is my source data:

1689932199711.png


When I try each individual criteria it works fine, but when I combine them it comes out with zero - can anyone help?

Thank you!!
 

Attachments

  • 1689932070003.png
    1689932070003.png
    7.6 KB · Views: 5

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
Welcome to the Board!

I have not analyzed your formula and data in great detail, but one thing stuck out to me like a sort thumb.

If you are copying this formula down rows, you will want to lock the row references for D29 and D30, i.e.
you should use D$29 and D$30 instead of D29 and D30 in your formula.

See if that fixes this issue. If not, we will need to do a deeper dive, in which case it would be helpful to actually having sample data we can copy and test on our side, instead of images.
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Hello, thank you for the response - I've added in a sample of the data which will hopefully help. I have now locked my date references as suggested but that hasn't worked unfortunately!

Mr Excel - Sample.xlsx
ABCDEFGHIJKLMNOPQRST
1Employee No.No.ForenamesSurnameJob TypeDepartmentStart DateTermination Date
212/31/221/31/232/28/233/31/234/30/235/31/233681xyzSales19/05/2021
31/31/232/28/233/31/234/30/235/31/236/30/233982xyzTechnical Support Services03/10/2022
4Heads per departmentJan-23Feb-23Mar-23Apr-23May-23Jun-233693xyzTechnical Support Services19/12/2014
51Administration0000003824xyzTechnical Support Services11/04/2016
61Chairman0000002775xyzExecutive17/03/2021
710Commercial0000004246xyzTechnical Support Services12/12/2022
811Compliance0000004067xyzFinance13/02/2023
914Contract0000004558xyzCommercial24/05/2021
101Executive0000003879xyzSales02/12/2013
114Finance00000042010xyzExecutive03/04/2009
125HR00000032811xyzProfessional Services01/03/2012
136IT00000046512xyzSales28/11/2017
147Marketing0000009613xyzOperations09/06/2014
158Operations00000049814xyzTelemarketing21/03/2023
163Pre-Sales00000029815xyzService08/07/2013
173Professional Services00000031316xyzService04/03/2019
1812Project00000048517xyzTelemarketing22/02/2023
1912Project Management00000046718xyzProject Management10/05/2010
202Sales00000045619xyzProfessional Services09/05/1994
212Sales-Comms00000044220xyzTechnical Support Services28/06/2021
222Sales-Print00000032721xyzSales-Comms13/09/2021
239Service00000048222xyzOperations26/01/2023
249Service Delivery00000015323xyzSales-Print27/04/2016
258Service Desk - Builds00000031924xyzOperations09/03/2020
2613Technical Support Services00000037925xyzTechnical Support Services09/05/2022
272Telemarketing00000047826xyzTechnical Support Services03/01/2023
282Telesales00000042127xyzProfessional Services03/08/2020
29TOTAL------46328xyzSales02/07/2019
3041329xyzProfessional Services07/06/2021
3131830xyzMarketing18/06/2007
3234531xyzService14/02/2022
3327332xyzOperations16/03/2020
3443033xyzTechnical Support Services20/06/2011
35134xyzOperations24/04/2006
3647035xyzSales18/02/2008
3739336xyzProfessional Services01/06/2010
3828337xyzExecutive17/05/2021
3947238xyzTechnical Support Services11/04/2022
4039439xyzProfessional Services12/12/2022
4148840xyzService13/03/2023
4241441xyzTechnical Support Services08/10/2015
43442xyzCommercial01/04/2003
4420543xyzFinance15/10/2018
KPIs
Cell Formulas
RangeFormula
E2:I2E2=D3
D5:I28D5=COUNTIFS($R:$R,KPIs!$B5,$S:$S,"<="&D$2,$T:$T,"")+COUNTIFS($R:$R,KPIs!$B5,$S:$S,"<="&D$2,Summary!$T:$T,">="&D$3)
D29:I29D29=SUM(D5:D28)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
M2:M65,M67:M215Cell ValueduplicatestextNO
 
Upvote 0
Your formula is referencing two different sheets (SUMMARY and KPIs).
Without see the data on all the different sheets, it is tough to day.

But for comparing dates, make sure ALL your date fields are formatted as Dates and not as Text!
One easy way to tell is to expand the size of the column. If your value is left-justified, it is probably text.
In the following example, the first and 3rd dates are text, not date entries:
1690200857497.png
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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