Forum Discussion

trying2learnpbi's avatar
trying2learnpbi
New Member
2 years ago
Solved

How to calculate dynamic percentage difference from the same column

Hello all, 

 

I am trying to calculate dynamically the percent difference using Price values from the same column and using filter context from two different columns (Month and Type)

 

I have been trying this measures formula below but I am sure my DAX is off.

Expense Calc = CALCULATE(SUM('Table1'[Price]),FILTER(ALL(('Table1'),[Type]="Expense" && 'Table1'),[Month]="April") )
Income Calc = CALCULATE(SUM('Table1'[Price]),FILTER(ALL(('Table1'),[Type]="Income" && 'Table1'),[Month]="April") )
percent diff = (Income Calc - Expense Calc)/Income Calc * 100
 
Additionally, if possible, I would like PBI to dynamic change the percent calc based on Month/Year Selected on the page? is this possible? 
See example below: 
 
MonthTypePrice
MarIncome$1000
MarExpense$500
AprilIncome$300
AprilExpense$800

7 Replies

  • Hi trying2learnpbi 

    My observation is that for your Expense Calc measure, you do not need to input hard corded "April" month, and similarly for your Income Calc, you do not need the hard coded "April" month filtering.  

    Your [percent diff] measure is just the margin and I wouldn't call it as percent diff as it is not describing what it is. 

    • trying2learnpbi's avatar
      trying2learnpbi
      New Member

      DataNinja777 thanks for the reply. I tried removing April but am getting error message (see screenshot below). Any help would be appreciated. 

       

  • Ajithkumar_03's avatar
    Ajithkumar_03
    Frequent Visitor

    Hi trying2learnpbi ,

    I hope this below Measures will help you,

    Measure 1:



    Measure 2:


    Measure 3:


    Dynamically it will work.


    Best Regards,
    Ajith Kumar

    If it solves your issue, please accept it as the solution to help the other members find it more quickly.

    • trying2learnpbi's avatar
      trying2learnpbi
      New Member

      Ajithkumar_03 thanks for your reply. I tried your format but am getting the error below. It is weird since the Type column has two values (income and expense). 

       

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  trying2learnpbi ,

     

    Is your problem solved? If it is solved, you can mark the correct answer as a marker, if it is not solved, you can provide detailed information we can help you better.

     

    Best Regards,

    Liu Yang

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