Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
trying2learnpbi
New Member

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 7
v-yangliu-msft
Community Support
Community Support

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.

Ajithkumar_03
Frequent Visitor

Hi @trying2learnpbi ,

I hope this below Measures will help you,

Measure 1:

Ajithkumar_03_0-1714924500342.png

Measure 2:

Ajithkumar_03_1-1714924556794.png


Measure 3:

Ajithkumar_03_2-1714924611024.png


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.

@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). 

 

trying2learnpbi_0-1714935488450.png

 

@trying2learnpbi 
Cosed bracket is missing. Please refer the below screenshot. 

Ajithkumar_03_0-1714973489696.png

 

DataNinja777
Super User
Super User

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. 

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

trying2learnpbi_0-1714919327981.png

 

Hi @trying2learnpbi 

Dax is like an excel formula.  You can delete the blue crossed out part.  

DataNinja777_0-1714920020663.png

Best regards,

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.