Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
eHorizons
Frequent Visitor

Create timepoint for observation based on dates

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?

IDDateTimepoint
1231/1/20232
5462/3/20231
87612/13/20221
1235/8/20211
8766/1/20232
1 ACCEPTED SOLUTION
AlienSx
Super User
Super User

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

View solution in original post

2 REPLIES 2
DallasBaba
Skilled Sharer
Skilled Sharer

@eHorizons You can create the Timepoint column in Power Query.

 

  1. Select the ID and Date columns by holding down the Ctrl key and clicking on each column header.
  2. Click on the Group By button in the Transform tab.
  3. In the Group By dialog box, select ID as the Group By column and click on the Advanced button.
  4. In the Advanced dialog box, enter Timepoint as the New column name and select Count Rows as the Operation. You can also enter a custom name for the Count Rows column if you prefer.
  5. Click on OK to close the Advanced dialog box and then click on OK again to close the Group By dialog box.
  6. The Timepoint column will be added to your table with the first observation for each person labeled as 1, the second observation labeled as 2, and so on.

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.

 

NOTEYou 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)

 

 

Please click Accept as a solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item.
 
If the content was helpful in other ways, please consider giving it a Thumbs Up.
 
Thanks
Dallas
AlienSx
Super User
Super User

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

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.