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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare 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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

October NL Carousel

Fabric Community Update - October 2024

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