Forum Discussion
Dividing two calculated columns
Hello everyone,
Recently I started to work with powerBI, and my calculations are not working properly. This is my data;
| KeyID | Process | Status |
| A1 | A | Error |
| A2 | A | Error |
| A3 | A | |
A4 | A | Success |
B1 | B | Error |
B2 | B | Success |
What I want to do is I want to create this table
| Process | Number of Error | Number of Error&Success | Number of Error/Number of Error&Success |
| A | 2 | 3 | 66,6% |
| B | 1 | 2 | 50,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
- Anonymous4 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_DecklerCommunity 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])
- AnonymousNot applicable
Hi Greg thank you for your reply but it is not working either..
- AnonymousNot 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.- AnonymousNot 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! 🙂