cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper II
Helper II

Success Rate (%) by category

Hello all!

 

I am struggling with what seems to be an easy task.

 

I have a table named "success" that looks like the one below. I have the Category and the Outcome, and I would like to calculate the Success Rate for each category, such that the numbers are as the ones indicated in the column "Success Rate". I tried different methods with Count and Filter but failed every time.  Thank you!

 

Category  Outcome  Success Rate

ATRUE100%
BFALSE0%
DTRUE100%
ATRUE100%
BFALSE50%
CFALSE50%
EFALSE50%
ATRUE100%
EFALSE50%
CTRUE50%
1 ACCEPTED SOLUTION
Super User IV
Super User IV

@Bob1410 - Here is the column you asked for. PBIX is attached below sig. Table (19)

Success Rate = 
    VAR __True = COUNTROWS(FILTER('Table (19)',[Category]=EARLIER([Category]) && [Outcome]))
    VAR __False = COUNTROWS(FILTER('Table (19)',[Category]=EARLIER([Category]) && NOT([Outcome])))
    VAR __Result = DIVIDE(__True,__True+__False,0)
RETURN
    IF(ISBLANK(__Result),0,__Result)

---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
Super User IV
Super User IV

@Bob1410 - Here is the column you asked for. PBIX is attached below sig. Table (19)

Success Rate = 
    VAR __True = COUNTROWS(FILTER('Table (19)',[Category]=EARLIER([Category]) && [Outcome]))
    VAR __False = COUNTROWS(FILTER('Table (19)',[Category]=EARLIER([Category]) && NOT([Outcome])))
    VAR __Result = DIVIDE(__True,__True+__False,0)
RETURN
    IF(ISBLANK(__Result),0,__Result)

---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Super User IV
Super User IV

@Bob1410 ,

A new measure like

Calculate(Divide(calculate(Count(Table[Outcome]),[Outcome] ="TRUE") ,Count(Table[Outcome])), allexcept(Table,Table[Category]))

 

 

Or a new column


column =
var _cnt =countx(filter(Table , [Category] =earlier([Category])),[Category])
var _cntTR =countx(filter(Table , [Category] =earlier([Category]) && [Outcome] ="TRUE"),[Category])
return
divide( _cntTR,_cnt)



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors