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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
pfarahani
Helper II
Helper II

Measure for Expenses Vs Budget

Hello, 

 

I have a pretty simple table in Power BI. It shows the actual expenses in one column and the budget for that year in the other column. I am trying to create a third column which shows the percentgae difference, if the expense are under the budget, by how much %, or if over, by how much. Any help, how I can create that measure. Thanks

pfarahani_0-1629501195002.png

 

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @pfarahani ,

 

According to your description, whether it is column or measure, a field type can only be the same. Therefore, even if the judgment condition is used, the result of percentage and numeric value cannot be displayed in the same column.

 

Two different results can only be obtained in the following ways, refer to the following:

Measure = 
var a = CALCULATE(SUM('Table'[Actual Expense]),ALLEXCEPT('Table','Table'[Fiscal Year]))
var b = CALCULATE(SUM('Table'[Budget Expense]),ALLEXCEPT('Table','Table'[Fiscal Year]))
return
IF(b>a,(b-a)/b,0)

vhenrykmstf_0-1629785844657.png

Measure = 
var a = CALCULATE(SUM('Table'[Actual Expense]),ALLEXCEPT('Table','Table'[Fiscal Year]))
var b = CALCULATE(SUM('Table'[Budget Expense]),ALLEXCEPT('Table','Table'[Fiscal Year]))
return
IF(b>a,0,-(b-a))


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

View solution in original post

2 REPLIES 2
v-henryk-mstf
Community Support
Community Support

Hi @pfarahani ,

 

According to your description, whether it is column or measure, a field type can only be the same. Therefore, even if the judgment condition is used, the result of percentage and numeric value cannot be displayed in the same column.

 

Two different results can only be obtained in the following ways, refer to the following:

Measure = 
var a = CALCULATE(SUM('Table'[Actual Expense]),ALLEXCEPT('Table','Table'[Fiscal Year]))
var b = CALCULATE(SUM('Table'[Budget Expense]),ALLEXCEPT('Table','Table'[Fiscal Year]))
return
IF(b>a,(b-a)/b,0)

vhenrykmstf_0-1629785844657.png

Measure = 
var a = CALCULATE(SUM('Table'[Actual Expense]),ALLEXCEPT('Table','Table'[Fiscal Year]))
var b = CALCULATE(SUM('Table'[Budget Expense]),ALLEXCEPT('Table','Table'[Fiscal Year]))
return
IF(b>a,0,-(b-a))


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

AllisonKennedy
Super User
Super User

@pfarahani Is [Actual Expenses] a column or measure?

 

If it's a measure, create a new measure:

 

% Diff = DIVIDE([Actual Expenses] - [Budget Expenses], [Budget Expenses])

 

If it's a column, create new measures:

 

Total Actual Expenses = SUM(Table[Actual Expenses])

Total Budget Expenses = SUM(Table[Budget Expenses])

 

and use the measures in the % Diff measure.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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