Forum Discussion

jereaallikko's avatar
jereaallikko
Icon for Helper III rankHelper III
5 years ago

DAX with Multiple IF Contains Statements

Hi all,

 

I am trying to figure out a simple DAX with multiple conditions:

 

If [Column] contains "This1" then "That1" elseif [Column] contains "This2" then "That2" elseif [Column] contains "This3" then "That3" else null

 

I know that this could easily be done with conditional or custom column, but for now I need to do it with DAX. Any suggestions How this could be done?

 

BR,

Jere

7 Replies

  • Tanushree_Kapse's avatar
    Tanushree_Kapse
    Icon for Impactful Individual rankImpactful Individual

    Hi jereaallikko ,

     

    Try this DAX:
    Measure= IF([Column]="This1","That",IF([Column]="This2","That2",IF([Column]="This3","That3")), BLANK())

     

    Mark this as a solution, if I answered your question.

    Kudos are always appreciated.

     

    Thanks!

  • Hi jereaallikko 

    Try this measure with IF:

    Measure =
    IF (
        [Column] = "This1",
        "That1",
        IF ( [Column] = "This2", "That2", IF ( [Column] = "This3", "That3", BLANK () ) )
    )

     

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

    Appreciate your Kudos✌️!!

     

  • Hi VahidDM & Tanushree_Kapse 

     

    What I meant, is that "This1" is included in the column. For instance, if a column value is "This1is", DAX will return "That1". Similarly, if the value is "This1isnot" it will still return "That1", because the value CONTAINS "This1"

    That is what I meant with CONTAINS, not equals (=).

     

    Any suggestions?

    • VahidDM's avatar
      VahidDM
      Icon for Super User rankSuper User

      jereaallikko 

      Can you share a sample of your table after removing sensitive data here?

       

      Appreciate your Kudo!!

      • jereaallikko's avatar
        jereaallikko
        Icon for Helper III rankHelper III

        Hi VahidDM 

         

        The table looks similar to this: 

         

        The "Country" Column is the one that I am trying to build with DAX. So when [Name] CONTAINS "FIN", it returns "Finland". Same goes with "GER", "Germany" & "RUS", "Russia".