We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hi Everyone!
I have a table like the one below with IDs that correspond to a specific person and dates of observation. I am wondering how to create the Timepoint column in bold below. I want to label the first, second, third, etc observation for each person based on the date field. Any ideas?
| ID | Date | Timepoint |
| 123 | 1/1/2023 | 2 |
| 546 | 2/3/2023 | 1 |
| 876 | 12/13/2022 | 1 |
| 123 | 5/8/2021 | 1 |
| 876 | 6/1/2023 | 2 |
Solved! Go to Solution.
hi, @eHorizons
let
Source = table_like_the_one_below,
gr = Table.Group(
Source, "ID",
{{"points", each Table.AddIndexColumn(Table.Sort(_, "Date"), "Timepoint", 1, 1)}}
),
expand = Table.ExpandTableColumn(gr, "points", {"Date", "Timepoint"})
in
expand
@eHorizons You can create the Timepoint column in Power Query.
If you want to label the observations in reverse order (i.e., the most recent observation labeled as 1), you can sort the table by ID and Date in descending order before performing the Group By operation.
NOTE: You can also archive the same result using a DAX Measure:
Timepoint = RANKX(FILTER(ALL('Table'), 'Table'[ID] = EARLIER('Table'[ID]) && 'Table'[Date] <= EARLIER('Table'[Date])), 'Table'[Date], , ASC)
hi, @eHorizons
let
Source = table_like_the_one_below,
gr = Table.Group(
Source, "ID",
{{"points", each Table.AddIndexColumn(Table.Sort(_, "Date"), "Timepoint", 1, 1)}}
),
expand = Table.ExpandTableColumn(gr, "points", {"Date", "Timepoint"})
in
expand
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 6 | |
| 4 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 11 | |
| 10 | |
| 7 | |
| 7 | |
| 6 |