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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Samuelroark01
New Member

Need help filtering a text column

Hi There,

 

I have a column called "Container_number". I need to filter the column to only show me:

 

1. Rows that have any non-numeric characters in the text

2. If any rows have more or less that 8 characters in the text

 

Note: The filter should not be sequential. Both filters should be against the original set of data.

 

 

 

Samuelroark01_0-1718124863350.png

 

3 ACCEPTED SOLUTIONS
jgeddes
Super User
Super User

You can add the following line to your query...

 

 

 

 

= Table.SelectRows(PREVIOUSSTEP, each Text.PositionOfAny([container_number], {"A".."Z"}) <> -1 or Text.PositionOfAny([container_number], {"a".."z"}) <> -1 or Text.Length([container_number]) <> 8 )

 

 

 

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

v-xinruzhu-msft
Community Support
Community Support

Hi,

Thanks for the solution @jgeddes  provided, and i want to offer some more information for user to refer to.

hello @Samuelroark01 , you can add a new step and input the following code.

 =Table.SelectRows(your last step name , each Text.Select([container_number],{"A".."Z","a".."z"})<>"" or  Text.Length([container_number])<>8)
//the last step name in your step, e.g #"Changed Type"

And you can refer to the following m code in advanved editor 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("NcexDcAwCATAXahT8HwAp0yyRCTE/mtEsuXurkqAsAyVPkpIBVJ5zd0wPvDl9/OYggdoi0bfOD1ySPcP", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [container_number = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"container_number", type text}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each Text.Select([container_number],{"A".."Z","a".."z"})<>"" or  Text.Length([container_number])<>8)
in
    #"Filtered Rows"

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

dufoq3
Super User
Super User

Hi @Samuelroark01, different approach:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Nc27EQAhCEXRXogNeIB8wq3Dsf82VneVgODMZRiD0JUaAS7hTLNtsSWqDARrHeu74ohM+CH/CZZ1L2ORQNLZ41B+FcPgax+sD7OgoT+t5426ZUBuVnt2KGr9iaQ5Xw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t, container_number = _t]),
    FilteredRows = Table.SelectRows(Source, each 
        [ a = Text.Length([container_number]),
          b = Text.Length(Text.Select([container_number], {"0".."9"})),
          c = (a <> b) or (a <> 8)
        ][c])
in
    FilteredRows

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

5 REPLIES 5
dufoq3
Super User
Super User

Hi @Samuelroark01, different approach:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Nc27EQAhCEXRXogNeIB8wq3Dsf82VneVgODMZRiD0JUaAS7hTLNtsSWqDARrHeu74ohM+CH/CZZ1L2ORQNLZ41B+FcPgax+sD7OgoT+t5426ZUBuVnt2KGr9iaQ5Xw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t, container_number = _t]),
    FilteredRows = Table.SelectRows(Source, each 
        [ a = Text.Length([container_number]),
          b = Text.Length(Text.Select([container_number], {"0".."9"})),
          c = (a <> b) or (a <> 8)
        ][c])
in
    FilteredRows

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

v-xinruzhu-msft
Community Support
Community Support

Hi,

Thanks for the solution @jgeddes  provided, and i want to offer some more information for user to refer to.

hello @Samuelroark01 , you can add a new step and input the following code.

 =Table.SelectRows(your last step name , each Text.Select([container_number],{"A".."Z","a".."z"})<>"" or  Text.Length([container_number])<>8)
//the last step name in your step, e.g #"Changed Type"

And you can refer to the following m code in advanved editor 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("NcexDcAwCATAXahT8HwAp0yyRCTE/mtEsuXurkqAsAyVPkpIBVJ5zd0wPvDl9/OYggdoi0bfOD1ySPcP", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [container_number = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"container_number", type text}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each Text.Select([container_number],{"A".."Z","a".."z"})<>"" or  Text.Length([container_number])<>8)
in
    #"Filtered Rows"

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

jgeddes
Super User
Super User

Yep. Replace that with the name of the previous step in your query as it appears in the advanced editor.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





jgeddes
Super User
Super User

You can add the following line to your query...

 

 

 

 

= Table.SelectRows(PREVIOUSSTEP, each Text.PositionOfAny([container_number], {"A".."Z"}) <> -1 or Text.PositionOfAny([container_number], {"a".."z"}) <> -1 or Text.Length([container_number]) <> 8 )

 

 

 

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Samuelroark01_0-1718138933871.png

It appears that the query does not like PREVIOUSSTEP

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!

December 2024

A Year in Review - December 2024

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

Top Kudoed Authors