Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Dividing two calculated columns

Hello everyone,

Recently I started to work with powerBI, and my calculations are not working properly. This is my data;

KeyIDProcessStatus
A1AError
A2AError
A3A 

A4

ASuccess

B1

BError

B2

BSuccess

What I want to do is I want to create this table

ProcessNumber of ErrorNumber of Error&SuccessNumber of Error/Number of Error&Success
A2366,6%
B1250,0%

What I did is;

Number of Error: IF(table[Status]="Error", 1,0)

Number of Error&Status: (IF(table[Status]="Error" || table[Status]="Success", 1,0))
Number of Error/Number of Error&Status: 
(table[Number of Error])/sum(table[Number of Error&Status])

First two calculations are working properly. But third one, where I calculate the percentage, is not calculating correctly. How could I do this calculation?

Thank you so much

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    Please try:

    Column = CALCULATE( SUM([Error])/ SUM([Error & Success]), ALLEXCEPT('Table','Table'[Process]))

     

    Or you could create measures instead:

    Number of Error = COUNTROWS(FILTER('Table',[Status]="Error"))
    Number of Error&Success = COUNTROWS(FILTER('Table',[Status] in {"Error","Success"}))
    % = DIVIDE( [Number of Error],[Number of Error&Success])

    Output:

     

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

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Anonymous Shouldn't that last one be:

    Number of Error/Number of Error&Status: sum(table[Number of Error]) / sum(table[Number of Error&Status])

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Greg thank you for your reply but it is not working either..

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Please try:

    Column = CALCULATE( SUM([Error])/ SUM([Error & Success]), ALLEXCEPT('Table','Table'[Process]))

     

    Or you could create measures instead:

    Number of Error = COUNTROWS(FILTER('Table',[Status]="Error"))
    Number of Error&Success = COUNTROWS(FILTER('Table',[Status] in {"Error","Success"}))
    % = DIVIDE( [Number of Error],[Number of Error&Success])

    Output:

     

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Eyelyn,

      First one somehow didn't work(Which I actually wanted to use column, instead of measure, cause I want to create group from column, which is not possible with measure). But the second one is working, thank you! 🙂