Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - count only distinct IDs per month

Status
Not open for further replies.

RosieGp

Programmer
Jun 23, 2009
83
US
Hello - I'm trying to count distinct ids per month. but it is not working for me.
Code:
worksheet1
    A       B                  C
1   ID      tempDate           DateValidation
2   12      11/12/2017         11/01/2017
3   14      12/23/2017         12/01/2017
4   16      11/17/2017         01/01/2017
5   20      11/11/2017
6   12      11/16/2017
7   16      11/01/2017
8   14      12/01/2017

what I'm trying to do is get the count of distinct ID per month. looking for the following output:
Nov 2017 3
Dec 2017 1
Jan 2018 0

so far i have:
Code:
=SUM(IF(FREQUENCY(A2:A8, A2:A8)>0,1))

it gives me 4. that is right but now i need it monthly.
as following:
Nov 2017 3
Dec 2017 1
Jan 2018 0

i also tried the following but i'm confused how to integrate distinct ID win it.
Code:
=IFERROR(COUNTIFS($B$2:$B$8,">="&$C$2, $B$2:$B$8,"<="&EOMONTH($C$2,0)),"")

Any help is appreciated. Thanks.
 
count distinct ids per month" would it help to have a (helper) column with just the Month?

[pre]
... D
... =MONTH(B2)
[/pre]


---- Andy

There is a great need for a sarcasm font.
 
tempDate is going to have 12/01/2018 onward dates so just month helper would have incorrect data, so I need month and year as well.

Thanks.
 
Using Named Ranges based on column headings...
[pre]
ID tempDate 12 14 16 20 Count

12 11/12/2017 11/1/2017 [highlight #FCE94F]2[/highlight] 0 2 1 [highlight #8AE234]3[/highlight]
14 12/23/2017 12/1/2017 0 2 0 0 1
16 11/17/2017 1/1/2018 0 0 0 0 0
20 11/11/2017 2/1/2018
12 11/16/2017
16 11/1/2017
14 12/1/2017
[/pre]
[tt]
[highlight #FCE94F]=SUMPRODUCT((tempDate>=$C2)*(tempDate<$C3)*(ID=D$1))[/highlight]
[highlight #8AE234]=SUMPRODUCT(--(D2:G2>0))[/highlight]
[/tt]


Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
So your original statement: "I'm trying to count distinct ids per month. but ..." was not correct, since you said later: "I need month and year as well." :-(


---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top