Forum Discussion

pagliaci's avatar
pagliaci
Frequent Visitor
4 years ago
Solved

Compare multiple values against target budget

 Hello, 

 

I have a powerbi where it shows me a report for the total $ spent in the departments, the database is the $ of each product bought, where I have a card that shows me the total amount and a table like this:

 

And I want to compare that with the target for the month for example:

 

My final result should be showing if the amount spent is within the target. I am having trouble to do this because my expenses are dynamic and my target is fixed, so when I try to put in a table together it keeps doing the avarage or sum. Does anyone have an idea on how to do it?

 

Thank you

 

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi pagliaci ,

     

    According to the code, I think you don't need to create a relationship between target table and expense table. We have added the filter in code.

     

    Best Regards,
    Rico Zhou

     

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

4 Replies

  • Please provide sanitized sample data that fully covers your issue. I cannot help you without meaningful sample data.
    Please paste the data into a table in your post or use one of the file services like OneDrive or Google Drive. I cannot use screenshots of your source data.
    Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

    https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

  • Hi pagliaci ,

     

    If your "Expense" table is as below, you can try to Unpivot [Target for Month] columns in "Targer" table in Power Query Editor.

    New Table:

    Then your calculation will be much easier.

    M_Expense = 
    CALCULATE(SUM(Expense[Expense]),FILTER(ALL(Expense),Expense[Department] = MAX(Target[Department])&& Expense[Month] in VALUES(Target[Month]))) 
    Measure = IF([M_Expense]> SUM(Target[Target]),"Yes","No")

    Result is as below.

     

    Best Regards.

     

    • pagliaci's avatar
      pagliaci
      Frequent Visitor

      Thank you. What relations should I make? Because I need to filter by department and by date

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi pagliaci ,

         

        According to the code, I think you don't need to create a relationship between target table and expense table. We have added the filter in code.

         

        Best Regards,
        Rico Zhou

         

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