How to count unique days in 2 different columns that are within an specific month?

reivillar

New Member
Joined
Mar 2, 2014
Messages
2
How can I create a formula that counts the unique days in 2 different columns within a specific month? (result in cells F3 and F4)

In the example below: 4 unique days for Oct/2020 and 5 unique days in Nov/2020.

Thanks in advance!



1635992988274.png
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Is month in column E: Real date (formatted as "mmm-yy") or text string?
Any problem if, it to be real 1st day of month: "1-Oct-2020"?
 
Upvote 0
With my suggest in #2
Reference instruction guide how to build it in: Count unique distinct values in two columns

Book1
ABCDEF
1
223-Oct-21xx28-Oct-21MonthCount
326-Oct-21y04-Nov-2101-Oct-214
426-Oct-21xx04-Nov-2101-Nov-215
526-Oct-21y04-Nov-21
626-Oct-21t04-Nov-21
722-Oct-21r04-Nov-21
822-Oct-21g04-Nov-21
922-Oct-21h05-Nov-21
1005-Nov-21j06-Nov-21
1105-Nov-21k06-Nov-21
1205-Nov-21l06-Nov-21
1305-Nov-21;09-Nov-21
1426-Oct-21i10-Nov-21
Sheet2
Cell Formulas
RangeFormula
F3:F4F3=SUM(IF($A$2:$A$14>=$E3,IF($A$2:$A$14<EDATE($E3,1),1/COUNTIFS($A$2:$A$14,">="&$E3,$A$2:$A$14,"<"&EDATE($E3,1),$A$2:$A$14,$A$2:$A$14))))+SUM(IF(COUNTIF($A$2:$A$14,$C$2:$C$14)=0,IF($C$2:$C$14>=$E3,IF($C$2:$C$14<EDATE($E3,1),1/COUNTIFS($C$2:$C$14,">="&$E3,$C$2:$C$14,"<"&EDATE($E3,1),$C$2:$C$14,$C$2:$C$14)))))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
If you have Excel 365, the shorter G3 formula should work:

Book1
ABCDEFGH
1
210/23/2021xx10/28/2021MonthCount
310/26/2021y11/4/202110/1/2021444
410/26/2021xx11/4/202111/1/2021555
510/26/2021y11/4/2021
610/26/2021t11/4/2021
710/22/2021r11/4/2021
810/22/2021g11/4/2021
910/22/2021h11/5/2021
1011/5/2021j11/6/2021
1111/5/2021k11/6/2021
1211/5/2021l11/6/2021
1311/5/2021;11/9/2021
1410/26/2021i11/10/2021
15
Sheet10
Cell Formulas
RangeFormula
F3:F4F3=SUM(IF($A$2:$A$14>=$E3,IF($A$2:$A$14<EDATE($E3,1),1/COUNTIFS($A$2:$A$14,">="&$E3,$A$2:$A$14,"<"&EDATE($E3,1),$A$2:$A$14,$A$2:$A$14))))+SUM(IF(COUNTIF($A$2:$A$14,$C$2:$C$14)=0,IF($C$2:$C$14>=$E3,IF($C$2:$C$14<EDATE($E3,1),1/COUNTIFS($C$2:$C$14,">="&$E3,$C$2:$C$14,"<"&EDATE($E3,1),$C$2:$C$14,$C$2:$C$14)))))
G3:G4G3=SUM(IF(COUNTIF($A$2:$A$14,SEQUENCE(EOMONTH(E3,0)-E3+1,,E3))+COUNTIF($C$2:$C$14,SEQUENCE(EOMONTH(E3,0)-E3+1,,E3)),1))
H3:H4H3=SUM(IF(MMULT(COUNTIF(OFFSET($A$2:$A$14,0,{0,2}),SEQUENCE(EOMONTH(E3,0)-E3+1,,E3)),{1;1}),1))
Press CTRL+SHIFT+ENTER to enter array formulas.


If the columns to check are the same size but just separated by some number of columns, you can get even shorter with the H3 formula.

These formulas are backward compatible with earlier versions of Excel by replacing the SEQUENCE function:

Book1
ABCDEFGH
1
210/23/2021xx10/28/2021MonthCount
310/26/2021y11/4/202110/1/2021444
410/26/2021xx11/4/202111/1/2021555
510/26/2021y11/4/2021
610/26/2021t11/4/2021
710/22/2021r11/4/2021
810/22/2021g11/4/2021
910/22/2021h11/5/2021
1011/5/2021j11/6/2021
1111/5/2021k11/6/2021
1211/5/2021l11/6/2021
1311/5/2021;11/9/2021
1410/26/2021i11/10/2021
15
Sheet2
Cell Formulas
RangeFormula
F3:F4F3=SUM(IF($A$2:$A$14>=$E3,IF($A$2:$A$14<EDATE($E3,1),1/COUNTIFS($A$2:$A$14,">="&$E3,$A$2:$A$14,"<"&EDATE($E3,1),$A$2:$A$14,$A$2:$A$14))))+SUM(IF(COUNTIF($A$2:$A$14,$C$2:$C$14)=0,IF($C$2:$C$14>=$E3,IF($C$2:$C$14<EDATE($E3,1),1/COUNTIFS($C$2:$C$14,">="&$E3,$C$2:$C$14,"<"&EDATE($E3,1),$C$2:$C$14,$C$2:$C$14)))))
G3:G4G3=SUM(IF(COUNTIF($A$2:$A$14,ROW(INDIRECT(E3&":"&EOMONTH(E3,0))))+COUNTIF($C$2:$C$14,ROW(INDIRECT(E3&":"&EOMONTH(E3,0)))),1))
H3:H4H3=SUM(IF(MMULT(COUNTIF(OFFSET($A$2:$A$14,0,{0,2}),ROW(INDIRECT(E3&":"&EOMONTH(E3,0)))),{1;1}),1))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0
Solution

Forum statistics

Threads
1,215,440
Messages
6,124,879
Members
449,192
Latest member
MoonDancer

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