Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
DAX_Noob82
Regular Visitor

Calculate % and Group by Value

Hi All,

 

I have a table which contains mulitple columns. 2 of those columns are 'Pass/Fail' & 'AgeGroup' containing the following values as a sample:

PassFailAgeGroup
Fail26-34
Pass18-35
Fail26-34
Pass36-50

How do I calculate the % to 100% of each age group in a 'Clustered Column Chart'?

I tried the following but it's not giving me a total of 100%:

%PassFail = VAR PassFailTotal = COUNT(Tablename[PassFail])
                   VAR AgeGroupTotal = CALCULATE(COUNT(Tablename[PassFail]), ALLEXCEPT(Tablename,SubjectHealth[AgeGroup]))
                   RETURN
 
            DIVIDE(PassFailTotal,
                      AgeGroupTotal)
 
Instead it give me this:
DAX_Noob82_0-1667531908146.png

Thanks.

 

1 ACCEPTED SOLUTION
ValtteriN
Super User
Super User

Hi, 

Try something like this:

Example data:

ValtteriN_0-1667544437983.png

Dax:

Pass/ fail for group =
var _c=
CALCULATE(COUNT('Table (10)'[Pass/Fail]),ALL('Table (10)'[Pass/Fail]))

var __category = COUNT('Table (10)'[Pass/Fail])

return
DIVIDE(__category,_c)


End result:

ValtteriN_1-1667545501773.png

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/







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

Proud to be a Super User!




View solution in original post

1 REPLY 1
ValtteriN
Super User
Super User

Hi, 

Try something like this:

Example data:

ValtteriN_0-1667544437983.png

Dax:

Pass/ fail for group =
var _c=
CALCULATE(COUNT('Table (10)'[Pass/Fail]),ALL('Table (10)'[Pass/Fail]))

var __category = COUNT('Table (10)'[Pass/Fail])

return
DIVIDE(__category,_c)


End result:

ValtteriN_1-1667545501773.png

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/







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

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.