Forum Discussion

TomLU123's avatar
TomLU123
Helper III
8 years ago
Solved

Validate the Data value with non-numerical characters

Dear experts, 

 

I am building a report to validate report to validate the Participant ID stored in the Participant Table. I wish to add a custom column "Participant ID Validation Result" by checking wheather the values contain any non-numerical chracters. If it is all number, the result will be valid. If it contains any non-numerical characters, it will show invalid.

 

Participant Table:

 

Is it possible to write any expressions to achieve this?

Many thanks!

 

4 Replies

  • Stachu's avatar
    Stachu
    Community Champion

    in query editor add a new column with this syntax

    if Text.Length([Participant ID])=Text.Length(Text.Select([Participant ID],List.Transform({0..9},each Number.ToText(_)))) then "Valid" else "Invalid"

    this is M solution, not DAX

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion
    Column = IF(ISERROR(VALUE([Participant ID])),"Invalid","Valid")

    DAX 

    • TomLU123's avatar
      TomLU123
      Helper III

      Hi Greg,

       

      Just a follow up quesion if we use following condition:

      If it is all number, the result will be valid. If it contains any non-numerical characters OR blank, it will show invalid.

      NameParticipant IDParticpant ID Validation Result
      Smith4222TInvalid
      David Invalid
      Jim5123同Invalid
      Celia5922¥Invalid
      Jessica52221Valid

       

      In that case, how should we modify the DAX to achieve that?

      Many thanks!

       

      Greg_Deckler

      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion

        I believe:

         

        Column = IF(ISBLANK([Participant ID]) || ISERROR(VALUE([Participant ID])),"Invalid","Valid")