Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Stacked Bar Chart Percentage

Hello -

I'm trying to get my stacked bar chart to display as a percentage.  I'm able to get the proper count values to display in the chart, but can't figure out what expression i would use to turn them into a percentage.

Both methods get me the proper counts

(single dimension with 2 measures):

Dimension:

Name

Measures:

Count({$<PrepQualityScore= {Acceptable}>} distinct Procedure)

Count({$<PrepQualityScore= {Unacceptable}>} distinct Procedure)

Two dimensions with singe measure:

Dimension:

Name

PrepQualityScore

Measure:

Count(distinct Procedure)

Any and all help is greatly appreciated.

Matt

7 Replies
sunny_talwar

May be try this as expression:

Dimension:

Name

PrepQualityScore


Measure:

Count(DISTINCT Procedure)/Count(DISTINCT TOTAL <Name> Procedure)

Assuming Name is your first dimension, this will give 100% for each of the bar (Name on the x-axis)

Not applicable
Author

That did get me to 100%; however, not the exact result I'm looking for.  I apologize, let me try and clarify the request.

For PrepQualityScore there are two values. Either Acceptable or Unacceptable.  When I create a stacked bar chart with Dimension as Name and PrepQualityScore and with a Measure =Count(distinct Procedure), I get something like the following:

X-Axis:  Name1,  Name 2, Name 3

Y-Axis:  (50 Acceptable,25 Unacceptable),  (60 Acceptable,20 Unacceptable), (20 Acceptable,30 Unacceptable)

What I would like is if I could get the Y-Axis to show something like

Y-Axis:  (67% Acceptable,33% Unacceptable),  (75% Acceptable,25% Unacceptable), (40% Acceptable,60% Unacceptable)

I've tried a bunch of things but can't seem to get it to work. I'm likely way over thinking this.  Example of my latest failed attempt:

(Count({$<PrepQualityScore= {Acceptable}>} distinct Procedure)/ Count(total <PrepQualityScore> distinct Procedure)) + (Count({$<PrepQualityScore= {Unacceptable}>} distinct Procedure) / Count(total <PrepQualityScore> distinct Procedure))

sunny_talwar

I guess the break up of the bar is exactly the same percentage, but Qlik Sense thus far doesn't show the numbers for each stack of the bar chart. Is the goal to get those percentages displayed in the stack bar chart?

Not applicable
Author

That would be ideal; however, I'd settle for being able to see the graph displayed as a 100% and see both Acceptable and Unacceptable stacked. Then if I clicked on either result, I could see the specific percentage.  OR,  I could create a reference line so I could quickly tell of Acceptable was above 90%.  (Still researching the reference line, but I'm pretty sure it's possible.)

Your initial expression got me to 100% for each name, but it doesn't show the split between Acceptable and Unacceptable.  This is where I'm stuck. 

sunny_talwar

That is very strange, It should have shown the split. Would you be able to share a sample where it isn't working for you?

Not applicable
Author

What is the easiest way to share?  I can't export the whole app as it contains some sensitive information.  I'll work on seeing if I can get this data stripped from the load so I can export unless there is an easier way to share?

sunny_talwar

Check these links out

Uploading a Sample