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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Mclovin100
Frequent Visitor

Barchart measure help

I have a tabble called D_events, I want to create a clustered bar chart that will be as follows
Y axis: % of reasons count
X axis: Reason
Legend: Year
I need to create a measure for ' % of reasons count' that will be sliced by Date, Class, Section which are available in the same table.
I created this measure which shows the % correctly only if im not slicing. for example if the data has 1 'reason' in 2020 out of the total of 2 reasons in 2020 it should calculated 1/2 but instead its calculating everything regardless of whats in the legend, x-axis. 

VAR SelectedReason = SELECTEDVALUE('D_Events'[Reason])
RETURN
DIVIDE(
CALCULATE(COUNTROWS('D_Events'), 'D_Events'[Reason] = SelectedReason),
CALCULATE(COUNTROWS('D_Events'), ALLSELECTED('D_Events'))
)

What adjustments I need to make to make this work the way it should be?

 

2 REPLIES 2
tamerj1
Super User
Super User

Hi @Mclovin100 

please try

=
DIVIDE (
COUNTROWS ( 'D_Events' ),
CALCULATE ( COUNTROWS ( 'D_Events' ), ALLSELECTED ( 'D_Events'[Reson] ) )
)

Its not working as expected 
for example in my clustred bar chart I  have one class value that should be %100 because its the only value in x axis and happened once in 2021, and the legened is for the year which is the 2021. Then it should show %100 but now its showing 8% because its looking at other "dates"

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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