Forum Discussion

arvindyadav's avatar
arvindyadav
Icon for Post Partisan rankPost Partisan
7 years ago

Need to use If Condition In Power BI Desktop.

Hi Team,

 

I want to establish If condition in power bi which I have made in excel i.e, =if(Profit > Average Profit/Employee , Profit, Average Profit/Employee).

So how I can make that type of formula in Power BI Desktop. 

I have a measure of Average Profit/Employee.

Please suggest me how to do =if(Profit > Average Profit/Employee, Profit, Average Profit/Employee) in Power BI Desktop.

 

Thanks,

Arvind

19 Replies

  • Hi arvindyadav,

     

    Since this is a measure the value of it changes accordingly to context, so when making the average Profit/Employee you need to change it filter context.

    Without additional information it's hard to give you a correct answer but you need to create something like this:

     

    Pofict per employee =
    IF (
        SUM ( Table[Profit] )
            > CALCULATE ( [Average Profit/Employee]; ALL ( Table[Employee] ) );
        SUM ( Table[Profit] );
        CALCULATE ( [Average Profit/Employee]; ALL ( Table[Employee] ) )
    )

    If you can share some sample data and expected result this measure can be made inline with your expectactions, again without any data difficult to respond.

     

    Regards,

    MFelix

    • arvindyadav's avatar
      arvindyadav
      Icon for Post Partisan rankPost Partisan

      Hi MFelix,

       

      Wow, it works but the total of Average per employee is displaying same as actual profit total. Why So?

       

      Thanks,

      Arvind

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

        Hi arvindyadav,

         

        Again without further information on your data is difficult to get the correct answer.

         

        It depends on the data model, the columns used on your visuals, etc.

         

        Can you share some sample?

         

        Regards,

        MFelix