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
smedina2020
New Member

Help with Percent on Stacked Bar Chart

Hi

I made a stacked bar chart to show gender data over a period of years, I was able to show the percent with this measure:

Gender % = DIVIDE(DISTINCTCOUNT('Table1'[PIDM]),CALCULATE(DISTINCTCOUNT('Table1'[PIDM]),ALLEXCEPT('Table1','Table1'[Year])))

Now the problem I have is that when I add a slicer (lets use state as example) when I click on one of the options the percent show is not within what is filtered.

Example: No slicer shows for 2014 61% Male and 39% Female click on Oregon state slicer and it shows 22% Male and 33% Female which clearly does not add 100%

What I'm doing wrong?

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@smedina2020 

 

You may refer to the post below.

https://community.powerbi.com/t5/Desktop/Percentages-to-multi-line-report/m-p/378504#M172040

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-chuncz-msft
Community Support
Community Support

@smedina2020 

 

You may refer to the post below.

https://community.powerbi.com/t5/Desktop/Percentages-to-multi-line-report/m-p/378504#M172040

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
jthomson
Solution Sage
Solution Sage

Probably something to do with the allexcept function you're using, I'm guessing that your numerator will count just Oregon in 2014, but the denominator will count every state in 2014, i.e. it'll show in your data 22% of 2014 is male in Oregon, because you're telling it to ignore every filter context except the year. Seems an unnecessarily complex formula to be honest

So... any sugestions?

I'd rewrite the formula, but without seeing your data model or data it's hard to do so, so just add whatever column you're feeding into the state filter into the allexcept bit of the existing measure

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.