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
jak8282
Helper III
Helper III

Find characters in a string

Is there a way to search for special characters in a string like below

 

"#*&%$£!^+;:?<>"
 
I want to say if it finds any of them its "Invalid"
1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @jak8282 

 

Download example PBIX file

 

In Power Query create a Custom Column with this

 

 

if List.ContainsAny(Text.ToList([String]),Text.ToList("#*&%$£!^+;:?<>")) then "Invalid" else "Valid"

 

 

txtsr.png

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

4 REPLIES 4
PhilipTreacy
Super User
Super User

Hi @jak8282 

 

If my answer worked for you please mark it as the answer so that others can benefit from learning how to solve this problem.

 

regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Kishore_KVN
Super User
Super User

Hello @jak8282  answer provided by @PhilipTreacy  is the best way. 

There is another method as well.. which is create a table with all special characters as below:

Kishore_KVN_0-1687175797522.png

 

Then in the actual table create a column using below DAX:

Check = 
IF(
    SUMX('Special Characters Table',FIND('Special Characters Table'[Characters],'Table'[Column],,0))>0,"Invalid","Valid")

Output looks like this:

Kishore_KVN_1-1687175848724.png

 

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

PhilipTreacy
Super User
Super User

Hi @jak8282 

 

Download example PBIX file

 

In Power Query create a Custom Column with this

 

 

if List.ContainsAny(Text.ToList([String]),Text.ToList("#*&%$£!^+;:?<>")) then "Invalid" else "Valid"

 

 

txtsr.png

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Thanks Phil - thats great

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.