Forum Discussion

InsightSeeker's avatar
InsightSeeker
Helper III
2 years ago
Solved

Need help with DAX

Hello   I need help to create a new column as per the below condition   If settle name is equal to Card or OCCF & code is equal to 000100160 & Number len is 11 & Number (Left 4) digits are 439...
  • ToddChitt's avatar
    2 years ago

    Use the IF ( ) DAX function, along with logical AND ( && ) and IN ( ) operators. Start by writing out the conditions in your native speaking language, which it looks like you have done. Then replace various parts with DAX functions:

    "

    If settle name is equal to Card or OCCF &

    code is equal to 000100160 &

    Number len is 11 &

    Number (Left 4) digits are 4398 &

    Number (right 4) digits are 1614 &  

    code is not blank

    then return valid else error."

     

    IF ( 'Table'[settle name] IN { "Card", "OCFF" } && 'Table'[code] = "000100160"... , "Valid", "Error" )

    I leave it to you, original poster, to fill in the blanks.

  • gmsamborn's avatar
    2 years ago

    Hi  InsightSeeker 

     

    Would this help?

     

    Column = 
    IF(
        [settle_name] IN { "Card", "OCCF" }
            && [Code] = "000100160"
            && LEN( [Number] ) = 11
            && LEFT( [Number], 4 ) = "4398"
            && RIGHT( [Number], 4 ) = "1614"
            && [Code.1] <> BLANK(),
        "Valid",
        "Error"
    )
    

     

     

    InsightSeeker.pbix

     

    (I added 2 more lines for testing.)