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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
royalsirrine
New Member

Using txt filter to only show results with a name that contains less than 15 characters.

When using the filter option in excel, we can use the text filter to create a view using the does not contain option and as the value enter ??????????????? to represent 15 characters. This will then show only items that have less than 15 characters in a host name. How can I mimic this kind of filter in PowerBI? It appears the "?" value does not carry over. 

Thx

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Using the GUI, apply any text filter to the column, say equals "a".

 

The query editor will then generate a step with code like 

= Table.SelectRows(#"Changed Type", each [Column1] = "a")

Now replace each [Column1] = "a" with the conditions you actually want.

= Table.SelectRows(#"Changed Type", each Text.Length([Column1]) < 15)

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @royalsirrine ,

 

Does the replies above solve your problem? If it has been solved, please mark the correct reply as the standard answer to help the other members find it more quickly.Thank you very much for your kind cooperation!

 

Hope it helps,


Community Support Team _ Caitlyn

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

AlexisOlson
Super User
Super User

Using the GUI, apply any text filter to the column, say equals "a".

 

The query editor will then generate a step with code like 

= Table.SelectRows(#"Changed Type", each [Column1] = "a")

Now replace each [Column1] = "a" with the conditions you actually want.

= Table.SelectRows(#"Changed Type", each Text.Length([Column1]) < 15)

@royalsirrine  or you can use fully qualified regex. 

 

smpa01_0-1633366477205.png

 

 

/^[A-Za-z]{6}$/gm

returns true for string with exact 6 characters in length

 

 

to use the above in PQ

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRydnFVitWJVkpMSk5JRbDSwUyQNFAwFgA=", 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}}),
    fx = let   fx =(input)=>
    Web.Page(
        "<script>
            var x='"&input&"';
            var b = x.match(/^[A-Za-z]{6}$/gm);
            document.write(b);
        </script>"){0}[Data]{0}[Children]{1}[Children]    
in
    fx,
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each fx([Column1])),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Text"}, {"Text"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded Custom", each ([Text] = "abcdeg"))
in
    #"Filtered Rows"

 

 

I wish this was also in DAX.

 

For complex regex, ask here or stackoverflow is your friend.

 

smpa01_1-1633366732369.png

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
parry2k
Super User
Super User

@royalsirrine I don't think wildcard functionality available in Power BI

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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