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

Join 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.

Reply
dbaber
Regular Visitor

Calculate sequential count of unique id in new field

Hello,

 

I am trying to sequentially number each time a repeaded ID is listed in a column. The table I am working with does not have a Key Field. To create a key field I would like to take the repeated ID in Column A and the the sequential number in Column B so I can create a concatentated unique field.

 

ID# of times the value occursConcatentated Key Field
1000110001
1000210002
1000310003
2000120001
3000130001
3000230002
3000330003
4000140001
4000240002
4000340003
5000150001

 

I've tried using Count, Distinctcount and Countrow functions, but I'm missing something.  

 

Thanks!

@dbaber

1 ACCEPTED SOLUTION
Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

Hi @dbaber - I have put together are example of how Power Query Table.Group function can be used to add index column based on the ID column.  To help you understand further please video this video on advanced Table.Group features: Advanced Group By Tricks in Power Query - YouTube

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwMFCK1cHGMIIxjDEYJrgZpmBGLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t]),
    #"Add Normal Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type),
    #"Group Row With ID Index" = Table.Group(#"Add Normal Index", {"ID"}, {{"ID Index", each Table.AddIndexColumn( _ , "ID Index", 1 , 1 ), type table [ID=nullable text, Index=Int64.Type, ID Index=Int64.Type]}}),
    #"ID Index" = Table.Combine( #"Group Row With ID Index"[ID Index] ),
    #"Add Final Index" = Table.AddColumn(#"ID Index", "Final ID Index", each Number.From([ID]) + [ID Index], Int64.Type)
in
    #"Add Final Index"

 

View solution in original post

1 REPLY 1
Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

Hi @dbaber - I have put together are example of how Power Query Table.Group function can be used to add index column based on the ID column.  To help you understand further please video this video on advanced Table.Group features: Advanced Group By Tricks in Power Query - YouTube

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwMFCK1cHGMIIxjDEYJrgZpmBGLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t]),
    #"Add Normal Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type),
    #"Group Row With ID Index" = Table.Group(#"Add Normal Index", {"ID"}, {{"ID Index", each Table.AddIndexColumn( _ , "ID Index", 1 , 1 ), type table [ID=nullable text, Index=Int64.Type, ID Index=Int64.Type]}}),
    #"ID Index" = Table.Combine( #"Group Row With ID Index"[ID Index] ),
    #"Add Final Index" = Table.AddColumn(#"ID Index", "Final ID Index", each Number.From([ID]) + [ID Index], Int64.Type)
in
    #"Add Final Index"

 

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.