Forum Discussion

karkar's avatar
karkar
Helper III
9 years ago
Solved

IN OPERATOR in PowerBi

 

 

I want to perform the following in Power Bi..

 

If Diagnosis_code  in('125','126', '127', '128') then category=Proc1

else if Diagnosis_code in('225','226', '227', '228') then category=Proc2

else category=Null

 

Thanks

  • Hi karkar,



    Thanks for the reply. I need help with the syntax while creating a column in the query editor.


    Based on my test, the formula(M) below should work in your scenario. :smileyhappy:

    = if List.Contains({125,126,127,128},[Diagnosis_code]) then "Proc1"
    else if List.Contains({225,226,227,228},[Diagnosis_code]) then "Proc2"
    else null

     

    Regards

8 Replies

  • dkay84_PowerBI's avatar
    dkay84_PowerBI
    Microsoft Employee

    You can either add a column in the query editor or use DAX to create a calculated column.  The syntax will differ depending on the choice.

     

    With DAX it essentially will be the same as an excel IF() statement, or you can use the SWITCH(TRUE()) type of argument which may offer performance improvement. 

    • karkar's avatar
      karkar
      Helper III

      Thanks for the reply. I need help with the syntax while creating a column in the query editor.

       

      Regards

      • v-ljerr-msft's avatar
        v-ljerr-msft
        Microsoft Employee

        Hi karkar,



        Thanks for the reply. I need help with the syntax while creating a column in the query editor.


        Based on my test, the formula(M) below should work in your scenario. :smileyhappy:

        = if List.Contains({125,126,127,128},[Diagnosis_code]) then "Proc1"
        else if List.Contains({225,226,227,228},[Diagnosis_code]) then "Proc2"
        else null

         

        Regards