Forum Discussion

pfarahani's avatar
pfarahani
Icon for Helper II rankHelper II
5 years ago
Solved

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

 

  • 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)

    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.

2 Replies

  • AllisonKennedy's avatar
    AllisonKennedy
    Icon for Community Champion rankCommunity Champion

    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.

  • v-henryk-mstf's avatar
    v-henryk-mstf
    Icon for Community Support rankCommunity 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)

    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.