Ordered Count for each Unique Entry

erahi

New Member
Joined
Jul 9, 2012
Messages
9
I have data in longitudinal format for patients. Each row denotes a treatment with patient column for Patient ID and date of treatment. I need a formula to work out an ordered count for each patient for their first treatment, second treatment, third treatment etc.
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Patient ID
Date
Ordered CountExplanation
Patient 125/05/20171Patient 1 treatment 1
Patient 328/05/20171Patient 3 treatment 1
Patient 103/06/20172Patient 1 treatment 2
Patient 315/06/20172Patient 3 treatment 2
Patient 418/07/20171Patient 4 treatment 1
Patient 120/07/20173Patient 1 treatment 3
Patient 123/07/20174Patient 1 treatment 4
Patient 427/07/20172Patient 4 treatment 2
Patient 315/08/20173Patient 3 treatment 3
Patient 216/08/20171Patient 2 treatment 1
Patient 110/09/20175Patient 1 treatment 5
Patient 201/10/20172Patient 2 treatment 2
Patient 312/10/20174Patient 3 treatment 4
Patient 101/11/20176Patient 1 treatment 6
Patient 204/11/20173Patient 2 treatment 3

<tbody>
</tbody>

The data can be sorted in any way, the formula continues to work

Formula in C2 copied down
=COUNTIFS(A:A,A2,B:B,"<"&B2)+1

Formula in D2 copied down
=A2&" treatment " &COUNTIFS(A:A,A2,B:B,"<"&B2)+1
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,175
Members
449,071
Latest member
cdnMech

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