Forum Discussion

jak8282's avatar
jak8282
Helper III
3 years ago
Solved

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"

4 Replies

  • 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"

     

     

     

    Regards

     

    Phil

  • 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:

     

    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:

     

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

  • 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