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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MichaelHutchens
Helper IV
Helper IV

Power Query Custom Column to count strings over 6 characters in length

Hi folks, I'm hoping someone might be able to help. I have a column with a large number of words in each row, and I'd like to create a custom column to count the instances of words in each row, but only where the words are 6 characters or longer.

 

Any help would be appreciated 🙂

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@MichaelHutchens , A new column in power query

 

List.Count( List.Select(List.Transform( Text.Split([Column1]," ") , each Text.Length(_) ), each _ >=6))

 

 

Test code for Power Query, paste in blank Query

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSkxKTklNU4BQ6RkgBhArxcYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Count( List.Select(List.Transform( Text.Split([Column1]," ") , each Text.Length(_) ), each _ >=6)))
in
    #"Added Custom"

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@MichaelHutchens , A new column in power query

 

List.Count( List.Select(List.Transform( Text.Split([Column1]," ") , each Text.Length(_) ), each _ >=6))

 

 

Test code for Power Query, paste in blank Query

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSkxKTklNU4BQ6RkgBhArxcYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Count( List.Select(List.Transform( Text.Split([Column1]," ") , each Text.Length(_) ), each _ >=6)))
in
    #"Added Custom"

Perfect! Thanks so much for the quick reply @amitchandak 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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