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
Jalolbek85
Regular Visitor

Count a set of consecutive digits

Hi All,

I want to count a set of consecutive digits from a product field called ‘Products’[Code].

Counting how many times the current digit appears consecutively from the current position.

For example.

  • For 488873383, the expected concatenated output should be 32 (set of three 8s and two 3s)
  • For 100, the concatenated output should be 2 (set of two 0s)
  • For 22798822, the concatenated output should be 222 (set of two 2s, two 8s, and another two 2s)

thanks

1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrGwsDA3NrYwVorViVYyNDAA00ZG5pYWFkZGSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Added Column" = Table.AddColumn(Source, "cnt", each Text.Combine(List.Transform(List.Select(Table.Group(Table.FromList(Text.ToList([Column1])), "Column1", {"grp", Table.RowCount}, 0)[grp], each _>1), Text.From)))
in
    #"Added Column"

ThxAlot_0-1727519484338.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



View solution in original post

2 REPLIES 2
ThxAlot
Super User
Super User

A better inspiration came up during my supper.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrGwsDA3NrYwVorViVYyNDAA00ZG5pYWFkZGSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Added Column" = Table.AddColumn(Source, "cnt", each Text.Combine(List.Transform(List.Select(List.Accumulate(Text.ToList([Column1]), {"", 0}, (s,c) => if c=s{0} then List.RemoveLastN(s) & {List.Last(s) + 1} else {c} & s & {1}), each try _>1 otherwise false), Text.From)))
in
    #"Added Column"

ThxAlot_0-1727551107320.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



ThxAlot
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrGwsDA3NrYwVorViVYyNDAA00ZG5pYWFkZGSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Added Column" = Table.AddColumn(Source, "cnt", each Text.Combine(List.Transform(List.Select(Table.Group(Table.FromList(Text.ToList([Column1])), "Column1", {"grp", Table.RowCount}, 0)[grp], each _>1), Text.From)))
in
    #"Added Column"

ThxAlot_0-1727519484338.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.