Forum Discussion

adoalan's avatar
adoalan
Helper III
3 years ago

Help with DAX Formula please

I have this piece of SQL code and I need to convert it in a DAX formula. 

I got half way through it and the below is working perfectly:

TESTAGAIN =
SWITCH(
    TRUE(),
    ISBLANK('nfp_giftaiddeclaration'[Forename]), "Yes",
    ISBLANK('nfp_giftaiddeclaration'[Surname]), "Yes",
    ISBLANK('nfp_giftaiddeclaration'[House]), "Yes",
    ISBLANK('nfp_giftaiddeclaration'[Postcode]), "Yes",
    "No")
 
How ever I can't incorporate the last part with 
IF(CONTAINSSTRING( nfp_giftaiddeclaration[Forename] , "&" ) || CONTAINSSTRING(nfp_giftaiddeclaration[Surname], "&" ), "Y", "N")
 
Somehow I m missing something here and I can't get it done. I get this error:

 

 
Can you help?
 
Many thanks 
 

9 Replies

  • Hi adoalan ,

    Please use the below i took it from your piece of example only,

     

    TESTAGAIN =
    SWITCH(
        TRUE(),
        ISBLANK('nfp_giftaiddeclaration'[Forename]), "Yes",
        ISBLANK('nfp_giftaiddeclaration'[Surname]), "Yes",
        ISBLANK('nfp_giftaiddeclaration'[House]), "Yes",
        ISBLANK('nfp_giftaiddeclaration'[Postcode]), "Yes",
        CONTAINSSTRING( nfp_giftaiddeclaration[Forename] , "&" ) || CONTAINSSTRING(nfp_giftaiddeclaration[Surname], "&" ), "Yes""No")
     
    Check if this solves the issue.
     
    Regards,
    Nikhil Chenna
     
    Appreciate with a Kudos!! (Click the Thumbs Up Button)
    Did I answer your question? Mark my post as a solution!
      • NikhilChenna's avatar
        NikhilChenna
        Skilled Sharer

        Hi adoalan ,

         

        Try this out then using IF condition 

         
            IF( 
            ISBLANK('nfp_giftaiddeclaration'[Forename]) || 
            ISBLANK('nfp_giftaiddeclaration'[Surname]) ||
            ISBLANK('nfp_giftaiddeclaration'[House]) ||
            ISBLANK('nfp_giftaiddeclaration'[Postcode]) ||
            CONTAINSSTRING( nfp_giftaiddeclaration[Forename] , "&" ) || 
            CONTAINSSTRING(nfp_giftaiddeclaration[Surname], "&" ), "Yes"
        "No")
         
        OR 
         
            IF( 
            'nfp_giftaiddeclaration'[Forename]=BLANK() || 
            'nfp_giftaiddeclaration'[Surname]=BLANK() ||
            'nfp_giftaiddeclaration'[House]=BLANK() ||
            'nfp_giftaiddeclaration'[Postcode]=BLANK() ||
            CONTAINSSTRING( nfp_giftaiddeclaration[Forename] , "&" ) || 
            CONTAINSSTRING(nfp_giftaiddeclaration[Surname], "&" ), "Yes"
        "No")
        This should work buddy.
         
        Regards,
        Nikhil Chenna
         

        Appreciate with a Kudos!! (Click the Thumbs Up Button)
        Did I answer your question? Mark my post as a solution!