Countifs before a certain date

andydarly

New Member
Joined
Oct 18, 2016
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hi, all. I am looking to do a countifs formula, which is usually pretty straightforward. However, one of the criteria needs to specify unque values

Please note that I am on a work computer and it will not let me download xl2bb, so had to use an image. Sorry. I did try :(

So in the attached data I would like to count unique entries for all the people in a team with "_D" in it, are 1 FTE and have a start date of before the first of the next month, so July's data in this attachment would number 43. The number for August would be 44 and September would be 45 etc. The formula I am trying is below works but counts all entries, so is 20 higher for each month. Is there a simple way to do this unique value part? Thanks in advance.

My formula is =COUNTIFS($C:$C,"*_D*",$D:$D,1,$F:$F,"<01/08/2022")

1667181866212.png
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
HI, all. I really appreciate your time spent on this but I cannot get either to work.

I have a countif that takes me most of the way there but instead of displaying it's result of 13 (for example) I would want that final result to have any duplicates removed so it recalculated to 7 (for example). I was hoping I guess for something along the lines of

=unique("result of my countifs formula","based on this criteria"). I just can't unravel your solutions into what I need in my small brain :(
 
Upvote 0
have any duplicates removed
You have not specifically stated what you mean by "duplicates". I have assumed that you simply mean "duplicate" names that meet all the other criteria. For example, in my sample below all dates are before the K1 date so I have assumed that we are looking for unique (=distict as you mentioned in post 2) names that have "_D" in col C and are FTE=1. In that case my formula below is counting the green rows and not counting the amber duplicate of "Ruiters, Kagiso".

If that is not doing what you want then please clarify what result I should have and why.

If that is doing what you want but is not working for you, then perhaps you could provide a small set of sample data (with XL2BB so that we can copy and be sure to be using the same data as you) where the formula is not working and explain in relation to that sample data what the result should be and why.

andydarly.xlsm
ABCDEFGHIJK
1EMP_IDEMP_SHORT_NAMEEMP_CLASS_1FTEHoursSTART_DATEStart Date Before1/11/2022
2NG0081Ngcobo, KhanyisileService_D JHB217518/09/2017Count6
3NG0081Ngcobo, KhanyisileService_N JHB91751/04/2022
4SA0576Saba, LindaService_D JHB317518/09/2017
5SA0576Saba, LindaService_N JHB61751/04/2022
6SE0236Seqobane, JenniferService_N JHB917522/03/2022
7SE0236Seqobane, JenniferService_N JHB51751/07/2022
8JI0334Mokgosi, XolileService_N JHB81751/01/2022
9JI0334Mokgosi, XolileService_N JHB41751/08/2022
10JI0334Mokgosi, XolileService_N JHB101751/09/2022
11KG0186Kgasane, LesegoService_D JHB51751/10/2020
12MA0987Mabetoa, OlgarService_N JHB11752/12/2021
13TS0257Tsholetsasne, BoitumeloService_N JHB51751/12/2021
14ZU0768Zulu, FaithService_N JHB1017518/09/2017
15ZU0768Zulu, FaithService_N JHB81751/07/2022
16ZU0768Zulu, FaithService_N JHB717522/08/2022
17GO1158Golding, NicoletteService_D JHB51601/03/2021
18MA0293Mazibuko, Thuli-NonkonzoService_D JHB80.8601/01/2022
19MA0293Mazibuko, Thuli-NonkonzoService_D JHB40.8601/10/2022
20BA0178Banda, NtandoService_N JHB40.8601/10/2020
21BA0178Banda, NtandoService_N JHB80.8601/02/2022
22MP5608Mphahlele, Ouma VickyService_N JHB51751/12/2021
23MP5608Mphahlele, Ouma VickyService_N JHB81751/07/2022
24MP5608Mphahlele, Ouma VickyService_D JHB51751/09/2022
25RU5561Ruiters, KagisoService_D JHB81751/01/2021
26RU5561Ruiters, KagisoService_D JHB41751/10/2022
Sheet1
Cell Formulas
RangeFormula
K2K2=IFNA(ROWS(UNIQUE(FILTER(B2:B26,(ISNUMBER(SEARCH("_D",C2:C26)))*(D2:D26=1)*(F2:F26<K1),NA()))),0)
 
Upvote 0
Solution
You have not specifically stated what you mean by "duplicates". I have assumed that you simply mean "duplicate" names that meet all the other criteria. For example, in my sample below all dates are before the K1 date so I have assumed that we are looking for unique (=distict as you mentioned in post 2) names that have "_D" in col C and are FTE=1. In that case my formula below is counting the green rows and not counting the amber duplicate of "Ruiters, Kagiso".

If that is not doing what you want then please clarify what result I should have and why.

If that is doing what you want but is not working for you, then perhaps you could provide a small set of sample data (with XL2BB so that we can copy and be sure to be using the same data as you) where the formula is not working and explain in relation to that sample data what the result should be and why.

andydarly.xlsm
ABCDEFGHIJK
1EMP_IDEMP_SHORT_NAMEEMP_CLASS_1FTEHoursSTART_DATEStart Date Before1/11/2022
2NG0081Ngcobo, KhanyisileService_D JHB217518/09/2017Count6
3NG0081Ngcobo, KhanyisileService_N JHB91751/04/2022
4SA0576Saba, LindaService_D JHB317518/09/2017
5SA0576Saba, LindaService_N JHB61751/04/2022
6SE0236Seqobane, JenniferService_N JHB917522/03/2022
7SE0236Seqobane, JenniferService_N JHB51751/07/2022
8JI0334Mokgosi, XolileService_N JHB81751/01/2022
9JI0334Mokgosi, XolileService_N JHB41751/08/2022
10JI0334Mokgosi, XolileService_N JHB101751/09/2022
11KG0186Kgasane, LesegoService_D JHB51751/10/2020
12MA0987Mabetoa, OlgarService_N JHB11752/12/2021
13TS0257Tsholetsasne, BoitumeloService_N JHB51751/12/2021
14ZU0768Zulu, FaithService_N JHB1017518/09/2017
15ZU0768Zulu, FaithService_N JHB81751/07/2022
16ZU0768Zulu, FaithService_N JHB717522/08/2022
17GO1158Golding, NicoletteService_D JHB51601/03/2021
18MA0293Mazibuko, Thuli-NonkonzoService_D JHB80.8601/01/2022
19MA0293Mazibuko, Thuli-NonkonzoService_D JHB40.8601/10/2022
20BA0178Banda, NtandoService_N JHB40.8601/10/2020
21BA0178Banda, NtandoService_N JHB80.8601/02/2022
22MP5608Mphahlele, Ouma VickyService_N JHB51751/12/2021
23MP5608Mphahlele, Ouma VickyService_N JHB81751/07/2022
24MP5608Mphahlele, Ouma VickyService_D JHB51751/09/2022
25RU5561Ruiters, KagisoService_D JHB81751/01/2021
26RU5561Ruiters, KagisoService_D JHB41751/10/2022
Sheet1
Cell Formulas
RangeFormula
K2K2=IFNA(ROWS(UNIQUE(FILTER(B2:B26,(ISNUMBER(SEARCH("_D",C2:C26)))*(D2:D26=1)*(F2:F26<K1),NA()))),0)
Hi, I might not be explaining myself very well.

I'm sorry. I do struggle with things like that
 
Upvote 0
So, are you all good now or do you still need help?
 
Upvote 0
Hi, all. I managed to have a play and get the correct numbers by combining COUNTA, UNIQUE and FILTER functions

Thank you all for your contributions
 
Upvote 0
Im not sure how to close the thread?
We don't close threads in this forum. Even when a successful suggestion has been made and accepted, it is always possible that an even better solution might be posted later.
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,436
Members
449,083
Latest member
Ava19

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