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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
amcneil32
Frequent Visitor

index number for each group

This is my dataset:

 

ID            Work Date      Clock In          

27615  8/14/2022   8/14/2022 9:00  
276158/14/20228/14/2022 15:30
276158/14/20228/15/2022 0:00
276158/17/20228/17/2022 0:00
276158/17/20228/17/2022 6:30
276158/18/20228/18/2022 0:06
276158/18/20228/18/2022 5:48
276158/19/20228/19/2022 0:06
276158/20/20228/20/2022 0:06
276158/20/20228/20/2022 6:36

 

and I need to create an Order column that outputs this:

 

 

ID              Work Date    Clock In                  Order

27615    8/14/2022    8/14/2022 9:00   1
276158/14/20228/14/202215:302
276158/14/20228/15/2022 0:003
276158/17/20228/17/2022 0:001
276158/17/20228/17/2022 6:302
276158/18/20228/18/2022 0:061
276158/18/20228/18/2022 5:482
276158/19/20228/19/2022 0:061
276158/20/20228/20/2022 0:061
276158/20/20228/20/2022 6:362

 

at the moment i am grouping and creating an indexing column, but it gives me this:

 

 

ID              Clock In                              Order

27615    8/14/2022 9:00:00 AM      1
276158/14/2022 3:30:00 PM2
276158/15/2022 12:00:00 AM3
276158/17/2022 12:00:00 AM4
276158/17/2022 6:30:00 AM5
276158/18/2022 12:06:00 AM6
276158/18/2022 5:48:00 AM7
276158/19/2022 12:06:00 AM8
276158/20/2022 12:06:00 AM9
276158/20/2022 6:36:00 AM10

 

 

 

#"Grouped Rows" = Table.Group(#"Renamed Columns", {"ID"}, {{"Count", each _, type table [ID=text, Work Date=nullable date, Clock In=nullable datetime]}}),
#"Added Custom1" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Count],"Index",1)),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom1", "Custom", {"Clock In", "Index"}, {"Clock In", "Index"}),
#"Removed Columns1" = Table.RemoveColumns(#"Expanded Custom",{"Count"}),
#"Renamed Columns2" = Table.RenameColumns(#"Removed Columns1",{{"Index", "Order"}})
in
#"Renamed Columns2"

 

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@amcneil32 , refer this nested index video from Curbal for power query

https://www.youtube.com/watch?v=7CqXdSEN2k4

 

In Dax

a new column

rankx(filter(Table, [ID] = earlier([ID]) && [WorkDay] = earlier([WorkDay])  ), [Clock In],,desc, dense)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@amcneil32 , refer this nested index video from Curbal for power query

https://www.youtube.com/watch?v=7CqXdSEN2k4

 

In Dax

a new column

rankx(filter(Table, [ID] = earlier([ID]) && [WorkDay] = earlier([WorkDay])  ), [Clock In],,desc, dense)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.