Cumulative Counting in column

antman123

Board Regular
Joined
Jan 24, 2005
Messages
72
Hi All,

I have a data set that is ordered by day. Each day can have up to 4 rows. For each day the row has another column to determine if it's a high tide or low tide (simply by and H or L).

I need to create a column that for each day will count the number of high tides and low tide values.

In the example below I am looking for a way to create the count in column C.

E.G

COLUMN A COL B COL C

01/01/2015 L 1
01/01/2015 H 1
01/01/2015 L 2
01/01/2015 H 2
02/01/2015 H 1
02/01/2015 H 2
02/01/2015 L 1
02/01/2015 H 3

Any help would be much appreciated.

Anthony
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
assume your data starts on row 1

use this in C1

=COUNTIFS($A$1:$A1,A1,$B$1:$B1,B1)

and drag down
 
Upvote 0
Thanks guys, that is amazing! If I wanted to make the scenario a bit more complicated, is this possible in Excel?

I know that there will never be more than 4 rows per day in my sheet, but there could be fewer than 4 rows per day. Knowing that, I would my count column (column C) to count the number of rows per day, then assign the count number based on the following logic:

The first H for a day will get the the number 1 assigned in column C
The second H for a day will get the number 3 assigned in column C
The first L for a day will get the number 2 assigned in column C
The second L for the day will get the number 4 assigned in column C

e.g.
E.G

COLUMN A COL B COL C

01/01/2015 L 2 (because it's the first L for the day)
01/01/2015 H 1 (because it's the first H for the day)
01/01/2015 L 4 (because it's the second L for the day)
01/01/2015 H 3 (because it's the second H for the day)
02/01/2015 H 1
02/01/2015 H 3
02/01/2015 L 2
Is this possible in Excel?

Instead of counting the number of times an H or L occurs in a particular day, I want to use the following logic:
 
Last edited:
Upvote 0
again, assuming data starts on row 1

in C1 enter

=IF(B1="L",CHOOSE(COUNTIFS($A$1:$A1,A1,$B$1:$B1,B1),2,4),IF(B1="H",CHOOSE(COUNTIFS($A$1:$A1,A1,$B$1:$B1,B1),1,3)))

and drag down
 
Upvote 0

Forum statistics

Threads
1,222,902
Messages
6,168,938
Members
452,227
Latest member
sam1121

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