Counting date occurrenceis for a list of non contiguous dates

taher9990

New Member
Joined
Feb 6, 2016
Messages
21
Dears kindly help me with this

I have this table The expected result is in column No. of Days
So it must count number of days for these Products (1010,1030,1040,1020)

I have this formula which give similar results but for dates that have gap like 21\01 then 24\01 here it will jump from 14 to 11 so the number of days will be 18,17,16,15,14,11

Code:
=INDIRECT(CONCATENATE("$B";"$";MIN(ROW([Date]))+ROWS([Date])-1))-B1



ID
Date
No. Days
1010
1/17/201618
1030
1/17/201618
10401/17/201618
10201/17/201618
10101/18/201617
10401/18/201617
10301/18/201617
10201/18/201617
10201/19/201616
10101/19/201616
10401/19/201616
10301/19/201616
10201/20/201615
10101/20/201615
10401/20/201615
10301/20/201615
10201/21/201614
10401/21/201614
10101/21/201614
10301/21/201614
10201/24/201613
10401/24/201613
10101/24/201613
10301/24/201613
10401/25/201612
10301/25/201612
10101/25/201612
10201/25/201612
10101/26/201611
10201/26/201611
10301/26/201611
10401/26/201611
10201/27/201610
10301/27/201610
10401/27/201610
10101/27/201610
10101/28/20169
10201/28/20169
10301/28/20169
10401/28/20169
10101/31/20168
10201/31/20168
10301/31/20168
10401/31/20168
10102/1/20167
10202/1/20167
10302/1/20167
10402/1/20167
10102/2/20166
10202/2/20166
10302/2/20166
10402/2/20166
10102/3/20165
10202/3/20165
10302/3/20165
10402/3/20165
10102/4/20164
10202/4/20164
10302/4/20164
10402/4/20164
10102/7/20163
10202/7/20163
10302/7/20163
10402/7/20163
10102/8/20162
10202/8/20162
10302/8/20162
10402/8/20162
10102/9/20161
10202/9/20161
10302/9/20161

<colgroup><col><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
there are clearly 18 rows with 1010 all with different dates. Say if 2 dates were the same, would you want answer = 17 ?
 
Upvote 0
IDDate
101003/01/2016
103004/01/2016
101005/01/2016
102006/01/2016Count of DateDate
101007/01/2016ID03/01/201604/01/201605/01/201606/01/201607/01/201608/01/201609/01/2016Grand Total
104008/01/20161010322 31213
103009/01/20161020123112111
102003/01/20161030 2111117
102004/01/20161040241119
101005/01/2016Grand Total666665540
104006/01/2016
101007/01/2016
102008/01/2016
101009/01/2016
104003/01/2016
103004/01/2016
102005/01/2016
104006/01/2016
101007/01/2016a pivot table tells you how many 4 digit codes in the first column
103008/01/2016
101009/01/2016how many different dates in second column
104003/01/2016
101004/01/2016how many times a date is duplicated for a code
102005/01/2016(1010 has three 3/1/16, two 4/1/16, two 5/1/16 and no occurrences of 6/1/16)
104006/01/2016
103007/01/2016
101008/01/2016also how many times a particular date appears
102009/01/2016
101003/01/2016
102004/01/2016
103005/01/2016
104006/01/2016
102007/01/2016
102008/01/2016
104009/01/2016
101003/01/2016
101004/01/2016
102005/01/2016
103006/01/2016
104007/01/2016

<colgroup><col><col><col span="3"><col><col span="7"><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
Thanks a lot dude,
But that's not what I want, what I want is only to count how many times is that product appeared in the list and that counter must be decremented until the recent day in the list , the pivot table is giving a lot of info despite of it is useful an more elegant but it is not related to what I want,
What I want is exactly as I have shown in the first thread, I need the counter because I use it in another calculations e.g. If product hsa

ID DATE Counter
1010 14/05/2016 3
1020 14/05/2016 3
1030 14/05/2016 3
1010 15/05/2016 2
1020 15/05/2016 2
1030 15/05/2016 2
1010 16/05/2016 1
1020 16/05/2016 1
1030 16/05/2016 1

As you can see the recent date is counted as 1 and oldest date is counted as 3

Below formula is doing getting almost close the same result but if there is a gap in date e.g. 14/05 and then 16/05 the counter will be 1,2,5 it will not continue in the sequence

Code:
=INDIRECT(CONCATENATE("$B","$",MIN(ROW([Date]))+ROWS([Date])-1))-B1


A B C
ID DATE Counter
1010 13/05/2016 5
1020 13/05/2016 5
1030 13/05/2016 5
1010 16/05/2016 2
1020 16/05/2016 2
1030 16/05/2016 2
1010 17/05/2016 1
1020 17/05/2016 1
1030 17/05/2016 1
 
Upvote 0
Hello
make a back up file to test this

I don't know if I got this
this formula assumes that column A, starting in row 1, is populated with 1010, 1020, 1030, 1040
This formula assumes column B, starting in row 1, are your date

that said......
In cell C1 put a 1
In Cell C2, put this formula, Then Copy this formula as far down the work sheet as you need
Code:
=IF(A2=A1,C1+1,COUNTIF($A$2:A3, A2))

Thomas
 
Upvote 0
In C2 control+shift+enter, not just enter, and copy down:

=SUM(IF($A$2:$A$72 = $A2,IF($B2 < $B$2:$B$72,1)))+1
 
Upvote 0
In C2 control+shift+enter, not just enter, and copy down:

=SUM(IF($A$2:$A$72 = $A2,IF($B2 < $B$2:$B$72,1)))+1



It is giving the expected results as you can see in row 45 it reached to 1 then it starts counting again
thanks a lot


ID
Date
No. Days
1010
1/17/201611
1030
1/17/201611
1040
1/17/201611
1020
1/17/201611
1010
1/18/201610
10401/18/201610
10301/18/201610
10201/18/201610
10201/19/20169
10101/19/20169
10401/19/20169
10301/19/20169
10201/20/20168
10101/20/20168
10401/20/20168
10301/20/20168
10201/21/20167
10401/21/20167
10101/21/20167
10301/21/20167
10201/24/20166
10401/24/20166
10101/24/20166
10301/24/20166
10401/25/20165
10301/25/20165
10101/25/20165
10201/25/20165
10101/26/20164
10201/26/20164
10301/26/20164
10401/26/20164
10201/27/20163
10301/27/20163
10401/27/20163
10101/27/20163
10101/28/20162
10201/28/20162
10301/28/20162
10401/28/20162
10101/31/20161
10201/31/20161
10301/31/20161
10401/31/20161
101002/01/201618
102002/01/201618
103002/01/201618
104002/01/201617
101002/02/201617
102002/02/201617
103002/02/201617
104002/02/201616
101002/03/201616
102002/03/201616
103002/03/201616
104002/03/201615
101002/04/201615
102002/04/201615
103002/04/201615
104002/04/201614
101002/07/201614
102002/07/201614
103002/07/201614
104002/07/201613
101002/08/201613
102002/08/201613
103002/08/201613
104002/08/201612
101002/09/201612
102002/09/201612
1030
02/09/201612

<colgroup><col><col span="2"><col></colgroup><tbody>
</tbody>
 
Upvote 0
Sorry for the mistype, It is giving unexpected results, it not OK dude sorry for that.

In C2 control+shift+enter and copy down:

=IF(ISNUMBER(MATCH(B2,$B$1:B1,0)),VLOOKUP(B2,$B$1:C1,2,0),SUM(IF($A$2:$A$72=$A2,IF($B2<$B$2:$B$72,1)))+1)

Does this satisfy? If not, would you care to elaborate?
 
Upvote 0

Forum statistics

Threads
1,216,101
Messages
6,128,840
Members
449,471
Latest member
lachbee

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