Forum Discussion

toum's avatar
toum
Helper II
3 years ago
Solved

Matche DAX

Hello,

Could you pleaqe tell me how I can convert this code to DAX 

SEARCH("^[A-Za-z]{5}@[0-9]{2} .*", [Column], , , , 1) = 1, TRUE(), FALSE())

 

  • Here is a DAX solution using "DAX loops :D"

    VAR textNew = UPPER('Table'[Column1])
    VAR alphabet = SELECTCOLUMNS(GENERATESERIES(UNICODE("A"), UNICODE("Z")), "@Char", UNICHAR([Value]))
    VAR numbers = SELECTCOLUMNS(GENERATESERIES(0, 9, 1), "@Char", [Value])
    VAR characters = UNION(alphabet, numbers, ROW("@Char", "@"))
    VAR textLength = LEN(textNew)
    VAR numTable = SELECTCOLUMNS(GENERATESERIES(1, textLength, 1), "@Num", [Value])
    VAR charTable = ADDCOLUMNS(numTable, "@Char", MID(textNew, [@Num], 1))
    VAR checkTable =
        ADDCOLUMNS(
            charTable,
            "@Check",
            IF([@Char] IN characters, 0, 1)
        )
    VAR countValues = SUMX(checkTable, [@Check])

    RETURN {IF(countValues > 0, TRUE())}

    Screenshot has the formula with commnets:

     


     


     

5 Replies