Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Percentages Calc

Hello Power BI Community 

 

I have information about projects, lets say the following table:

ABC
IDCosts%
110015,87%
215023,81%
318028,57%
420031,75%
Total630100,00%

 

And I want to be able to calculate "partial %" when I apply a filter... Something like this:

ABCD
IDCosts%Partial %
12015,87%20,00%
26323,81%42,00%
37928,57%43,89%
48631,75%43,00%
Total248100,00% 

 

So the column "D" is the result of sum of costs of *FILTER*/sum of project costs

 

Any ideas?

Thank you in advance for your help! 

3 Replies

  • Anonymous 

    Try this measure. Replace the TABLE[COLUMN] with the column you use for filtering.

     

    Partial % = 
    DIVIDE(
      SUM(TABLE[COST]),
      CALCULATE(
           SUM(TABLE[COST]),
           ALL(TABLE[COLUMN])
      )
    )    

      

    ________________________

    If my answer was helpful, please consider Accept it as the solution to help the other members find it

    Click on the Thumbs-Up icon if you like this reply 🙂

    YouTube  LinkedIn

  • Anonymous ,partial % calculation is not clear

     

    may be

    divide(sum(Table[Cost]) , calculate(sum(Table[cost]), allselected(table)))

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Anonymous ,

     

    Here are the steps you can follow:

    1. Create calculcated column.

    % =
    var _1=CALCULATE(SUM('Table'[Costs]),FILTER('Table','Table'[ID]=EARLIER('Table (2)'[ID])) )
    var _2=SUM('Table'[Costs])
    return DIVIDE(_1,_2)
    Partial % =
    var _1=CALCULATE(SUM('Table'[Costs]),FILTER('Table','Table'[ID]=EARLIER('Table (2)'[ID])))
    var _2=CALCULATE(SUM('Table (2)'[Costs]),FILTER('Table (2)','Table (2)'[ID]=EARLIER('Table (2)'[ID])))
    return DIVIDE(_2,_1)

    2. Result.

    You can downloaded PBIX file from here.

     

    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.