Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi there,
I have this data set where each patient goes through different treatments (each row is a new treatment).
I would like to add a new column (using DAX) that creates a sequence of numbers from 1 to "N" for each Patient, being 1 assigned to the earliest date.
This is what the new column should look like:
Patient | Created on (d/mm/yyyy) | Treatment number (calculated column) |
Patient A | 16/08/2023 | 3 |
Patient A | 5/05/2023 | 2 |
Patient A | 25/03/2023 | 1 |
Patient B | 13/08/2023 | 2 |
Patient B | 5/05/2023 | 1 |
Patient C | 19/06/2023 | 1 |
Patient D | 8/09/2023 | 2 |
Patient D | 14/07/2023 | 1 |
Thanks!
Solved! Go to Solution.
Try the following formula in a calculated column:
Treatment Number = COUNTROWS(FILTER('Table', 'Table'[ Created on (d/mm/yyyy)] <= EARLIER('Table'[ Created on (d/mm/yyyy)]) && 'Table'[Patient] = EARLIER('Table'[Patient])))
It's working perfectly. Thanks, Vicky!
Try the following formula in a calculated column:
Treatment Number = COUNTROWS(FILTER('Table', 'Table'[ Created on (d/mm/yyyy)] <= EARLIER('Table'[ Created on (d/mm/yyyy)]) && 'Table'[Patient] = EARLIER('Table'[Patient])))
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
8 | |
8 | |
8 | |
6 |
User | Count |
---|---|
14 | |
12 | |
11 | |
9 | |
9 |