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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
afaherty
Helper V
Helper V

COALESCE not working in stacked bar chart, need another solution

Hello all!

I have survey data where there are 9 questions, and the answers are on a scale of 0-4:

4 = Consistently

3 = Inconsistently

2 = Minimally

1 = Not at all

0 = N/A

 

That's not important though.  I was using COALESCE to find the percentage of students (by grade) who answered with each response, with question # on the slicer.

 

So, slicer:

afaherty_0-1640115644459.png

 

Percentages in a matrix:

 

afaherty_1-1640115668308.png

I had used this measure to obtain the percentages:

Response % = COALESCE(DISTINCTCOUNT('Sheet2'[Index]),0)

 

But I want my stacked bar chart to match the matrix, and it does not.  So therefore I think I need a different DAX measure.

 

afaherty_2-1640115729295.png

 

 

I am not yet able to attach files here, as I don't have access to that feature yet. 

Here is the PowerBI file: 

Stacked Bar Chart HELP! 

 

Thanks in advance to anyone who can help!

 

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

It looks like the bar chart doesn't have an axis total quick calculation option, so you'll need to write your own explicit measure.

 

This should work for both the matrix and the bar chart without applying any 'Show value as' adjustments.

Response % =
DIVIDE (
    DISTINCTCOUNT ( 'Sheet2'[Index] ),
    CALCULATE (
        DISTINCTCOUNT ( Sheet2[Index] ),
        ALLSELECTED ( Sheet2[Survey Likert Response] )
    )
)

AlexisOlson_0-1640125903400.png

 

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

It looks like the bar chart doesn't have an axis total quick calculation option, so you'll need to write your own explicit measure.

 

This should work for both the matrix and the bar chart without applying any 'Show value as' adjustments.

Response % =
DIVIDE (
    DISTINCTCOUNT ( 'Sheet2'[Index] ),
    CALCULATE (
        DISTINCTCOUNT ( Sheet2[Index] ),
        ALLSELECTED ( Sheet2[Survey Likert Response] )
    )
)

AlexisOlson_0-1640125903400.png

 

@AlexisOlson Thank you! Perfect!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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