Shane Newman
Shane Newman

Reputation: 11

Need to create a running count (starting at 1) based on dates and names (using a loop?)

I have a dataset that looks like the following:

Employee Id|Date|Hours|Points
-----------------------------

There's several hundred employees and each has dozens of rows with different dates (and associated hours and points).

I need to write something that will assign a running count of days worked for each employee. It would start at 1 on their first day (based on the earliest date they worked) and then continue until there are no more days they worked. I also need to create a running total of their points.

Essentially I need it to look like this:

EmployeeId|Date|Hours|Points|Cumulative_days_worked|Cumulative_points_total
---------------------------------------------------------------------------

I don't even know where to start. Could anyone point me in the right direction?

Thanks

Upvotes: 0

Views: 37

Answers (1)

Dirk Reichel
Dirk Reichel

Reputation: 7979

As simple formula, you could use:

=COUNTIF(A$1:A2,A2)

For E2 (and copy down) to get the running number for each ID.

=SUMIF(A$1:A2,A2,D$1:D2)

Would be F2 (and copy down)

enter image description here

Upvotes: 2

Related Questions