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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
JoelTib
Frequent Visitor

DAX - Proportion Calculation across multiple groupings

Dear Power BI Community,

 

I would like some help with the calculation of a proportion across multiple groupings. 

 

Shown below is the table I am working on.   I have Age Categories running from 15-19, 20-24, 25-29,... up to 85+.  I then also have four K10 categories within each of these Age Categories.  I would like to calculate the percentage of people in each K10 category, for each Age Category.  

JoelTib_1-1699512162563.png

 

 

The '%' column is produced with a DAX measure, but it is not calculating what I need.  The DAX measure I am using is as follows: 

 

6.2 % K10 Cat =
DIVIDE(
    COUNT(HILDA[xwaveid]),
    CALCULATE(
        COUNT(HILDA[xwaveid]),
          ALL(HILDA[K10 Category], HILDA[K10 - Sort]),
          ALL(HILDA[Age Category], HILDA[Age Category - Sort])
    )
)

 

 

Any help with how I should amend this DAX measure to produce what I need, would be most welcome.  

 

Kind regards,

Joel

2 REPLIES 2
JoelTib
Frequent Visitor

Dear @amitchandak,

Many thanks for your reply.  Unfortunately, I don't think I was clear enough in my initial question.  

I have mocked up the following table in Excel to detail exactly what I would like the DAX measure to produce.

JoelTib_0-1699524731072.png

You will see that I would like the proportion of each K10 category (Low, Moderate, High, Very High) as a function of the total for each Age Category.  

Again, any assistance on how I can re-write my DAX expression to produce this would be wonderful.  

Kind regards,

Joel

amitchandak
Super User
Super User

@JoelTib ,

I think you need to remove year , vertical


6.2 % K10 Cat =
DIVIDE(
COUNT(HILDA[xwaveid]),
CALCULATE(
COUNT(HILDA[xwaveid]),
Removefilters(HILDA[Year])
)
)

 

 

For row wise sub total

 

6.2 % K10 Cat =
DIVIDE(
COUNT(HILDA[xwaveid]),
CALCULATE(
COUNT(HILDA[xwaveid]),
Removefilters(HILDA[K10 Category], HILDA[K10 - Sort],HILDA[Age Category], HILDA[Age Category - Sort])
)
)

 

How to Switch Subtotal and Grand Total in Power BI | Power BI Tutorials| isinscope: https://youtu.be/smhIPw3OkKA

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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