Forum Discussion

PGAT's avatar
PGAT
Helper III
6 years ago
Solved

IF - Multiple conditions

Hi, I have 3 x columns as condition, and my outcome will be a score number.  I am am new to DAX.  Can someone share with me what is wrong with my formula? No syntax error.  Do I put the score number alone like this if I want to use the score later in charts? Thank you.

 

  • Anonymous's avatar
    Anonymous
    6 years ago

    PGAT 
    You create the column in Query Editor which is M formula. I would recommend you to create a column with DAX not M query. The dax formula is something like:

     

    Column = SWITCH(True(),
    [BKR TYPE]="KCD" && [JOB TYPE]="OB" && [MODE]="SEA",3,
    [BKR TYPE]="KCD" && [JOB TYPE]="OB" && [MODE]="AIR",1.5,
    [BKR TYPE]="KCD" && [JOB TYPE]="IB" && [MODE]="SEA",2,
    ...
    ...
    ...)

     


    Paul Zheng _ Community Support Team
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

7 Replies

  • Hi PGAT ,

     

    First of all in Power BI there are the use of two languages DAX (front end) and M language on the query editor, you are showing a query formula so you are using M language.

     

    Don't really understand your question, what is going wrong with your data? Be sure to convert this column to number in order to use in charts.

  • Anonymous's avatar
    Anonymous
    Not applicable

    PGAT 
    You create the column in Query Editor which is M formula. I would recommend you to create a column with DAX not M query. The dax formula is something like:

     

    Column = SWITCH(True(),
    [BKR TYPE]="KCD" && [JOB TYPE]="OB" && [MODE]="SEA",3,
    [BKR TYPE]="KCD" && [JOB TYPE]="OB" && [MODE]="AIR",1.5,
    [BKR TYPE]="KCD" && [JOB TYPE]="IB" && [MODE]="SEA",2,
    ...
    ...
    ...)

     


    Paul Zheng _ Community Support Team
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • PGAT's avatar
      PGAT
      Helper III

      Thanks to the both of you. I didn't know the difference between DAX and M. 

       

      How do I create the column in DAX?  It seems complicated.  

       

      Currently, I tried to add customs column in query editor, and then to work out my IF.  

       

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        PGAT 

        After you close or close&apply from the power query editor. Power bi Desktop is worked with DAX calculation.



        Paul Zheng _ Community Support Team
        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.