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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors