Counting how in how many days an item appears, when some items may appear more than once in a day

DFRNZ1000

New Member
Joined
Dec 7, 2012
Messages
5
M2222 12/07/12
M2230 12/07/12
M1087 12/06/12
M2525 12/05/12
M2525 12/05/12
M8899 12/05/12

Above is an example of what I am working with. I am trying to get a count of how many times the values on the left appear. But in some cases those values occur more than once in a single day. If they occur once or more in a single day then I want them to count as 1. So if an item occurs three times in one day I want it to be counted once, but if an item occurs once on the 5th and once on the 6th then the count would be at two. Is there a formula I can use to complete this?

Thanks
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
DFRNZ1000,

I do not have time to attempt to reolve the below to a single formula.
So this is my best effort to do your count but using 2 'helper' columns.

The count is in column E in the row of the first instance of your column A value.


Excel 2007
ABCDE
1M222212/07/2012M22224110211
2M223012/07/2012M22304110211
3M108712/06/2012M10874107211
4M252512/05/2012M25254104113
5M252512/05/2012M2525410410
6M252512/02/2012M2525409511
7M108712/06/2012M1087410720
8M292512/05/2012M29254104111
9M252512/01/2012M2525409201
10M252512/02/2012M2525409510
Sheet3
Cell Formulas
RangeFormula
C1=A1&B1
D1=--(MATCH(C1,$C$1:$C$10,0)=ROW(C1))
E1=IF(MATCH(A1,$A$1:$A$10,0)=ROW(A1),SUMPRODUCT(--($A$1:$A$10=A1)*--($D$1:$D$10=1)),"")



Hope that gives you something to work with.
 
Upvote 0
There are probably more elegant solutions, but this will work (in several steps)

Assumptions:
Col A is Item Number (header in row 1)
Col B is Date (header in row 1)

Column C flag FIRST occurrence of an item on a given date:
C2 formula =IF(SUMPRODUCT((A$2:A2=A2)*(B$2:B2=B2))>1,0,SUMPRODUCT((A$2:A2=A2)*(B$2:B2=B2))) **Note placement of "$"
Copy down in Col C

Col D creat list of unique item numbers
D2 formula **NOTE: do not hit enter, use Control+Shift+Enter which will surround the formula with {}
=IF(ROWS($D$2:D2)>SUMPRODUCT(($A$2:$A$10<>"")/COUNTIF($A$2:$A$10,$A$2:$A$10&"")),"",INDEX($A$2:$A$10,MATCH(SMALL(IF(COUNTIF(OFFSET($A$2,0,0,ROW($A$2:$A$10)-ROW($A$2)+1,1),$A$2:$A$10)=1,COUNTIF($A$2:$A$10,"<"&$A$2:$A$10)),ROWS(D$2:$D2)),IF(COUNTIF(OFFSET($A$2,0,0,ROW($A$2:$A$10)-ROW($A$2)+1,1),$A$2:$A$10)=1,COUNTIF($A$2:$A$10,"<"&$A$2:$A$10)),0)))
Copy the formula down in Col D until it begins returning blank results

Col E count items per your description
E2 formula =SUMIFS(C:C,C:C,"1",A:A,D2)
Copy formula down in Col E
 
Upvote 0
M2222 12/07/12
M2230 12/07/12
M1087 12/06/12
M2525 12/05/12
M2525 12/05/12
M8899 12/05/12

Above is an example of what I am working with. I am trying to get a count of how many times the values on the left appear. But in some cases those values occur more than once in a single day. If they occur once or more in a single day then I want them to count as 1. So if an item occurs three times in one day I want it to be counted once, but if an item occurs once on the 5th and once on the 6th then the count would be at two. Is there a formula I can use to complete this?

Thanks
It's not real clear what you're wanting to do.

Do you want to count the unique DATES for the items in the left column ?

For example:

The count of unique dates for item M2525 would be 1.

Or, do you want something else?
 
Upvote 0
I have a list going back a few years with dates of everytime one of these M values occurred. There are about 100 different M values. I am trying to get a count of on how many days each M value occurs. The problem is that on some days a M value may be listed more than once, but I only want it to count as 1. If a M value occurs one or more times on a single day then it counts as one, but if it did not occur then it does not add to the count.
 
Upvote 0
I have a list going back a few years with dates of everytime one of these M values occurred. There are about 100 different M values. I am trying to get a count of on how many days each M value occurs. The problem is that on some days a M value may be listed more than once, but I only want it to count as 1. If a M value occurs one or more times on a single day then it counts as one, but if it did not occur then it does not add to the count.
Try this...

Book1
ABCDE
1CodeDate_CodeCount
2M112/5/2012_M13
3M112/5/2012_M21
4M112/9/2012_M32
5M112/10/2012___
6M212/1/2012___
7M312/2/2012___
8M312/3/2012___
9M312/3/2012___
10M312/3/2012___
Sheet1

With the unique codes in D2:Dn...

This array formula** entered in E2 and copied down:

=SUM(IF(FREQUENCY(IF(A$2:A$10=D2,B$2:B$10),B$2:B$10),1))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.

You can easily get the list of unique codes by using advanced filter:

http://contextures.com/xladvfilter01.html#FilterUR
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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