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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
hpatel24779
Helper II
Helper II

create a record number column for each person id

Hi All,

 

I have tried using index but not what i need. I want to create a new column with a record number starting from 0001 to 1300 if i have 1300 unique people in my data. For each id the record number increases by 1.

 

Example of what i require:

 

Person IDRecord Number
564630001
469790002
12340003
699560004
699560004
46920005
46920005
156520006

 

i will ensure my data is sorted by person id to be on safe side.

 

Is this achievable?

 

kind regards

 

Hetal

1 ACCEPTED SOLUTION
SamWiseOwl
Super User
Super User

Hi @hpatel24779 

 

Something like this?

Rank ID =
var r =
RANK(
    DENSE
    ,ORDERBY('Table'[Person ID], ASC) --rank by personID, DENSE keeps all numbers
    ,LAST --missing ranked last
)

RETURN
    REPT(0,4 - len(r)) & r --add 0s equal to 4 minus the number of characters in the rank 
 
SamWiseOwl_0-1736344962541.png

 

 

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

View solution in original post

3 REPLIES 3
SamWiseOwl
Super User
Super User

Hi @hpatel24779 

 

Something like this?

Rank ID =
var r =
RANK(
    DENSE
    ,ORDERBY('Table'[Person ID], ASC) --rank by personID, DENSE keeps all numbers
    ,LAST --missing ranked last
)

RETURN
    REPT(0,4 - len(r)) & r --add 0s equal to 4 minus the number of characters in the rank 
 
SamWiseOwl_0-1736344962541.png

 

 

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

Hi @SamWiseOwl 

 

exactly what i want. can this be done in power query?

 

kind regards

 

Hetal

I don't suppose you are using the online version...

https://learn.microsoft.com/en-us/power-query/rank-column


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.