Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to create multiple text values on Bar Chart

I keep getting asked this question and have been unable to find an acceptable working solution.

We have a bar chart that has two dimensions (entity and rating). We have one expression for the count.  The bar charts are stacked. I've attached a picture for reference.

The question we keep getting asked is can we have the percentage relative to one of the ratings along with the total number. In other words, if entity "ABC" has 100 Pass ratings and 5 Marginal Rating and 10 Fail Ratings, the user would like to see the total count and the percentage of fails next to each bar on the chart. So the display for this entity would show for example "115 / 8.70%".

Obviously, we can create tables of numbers that show this information, but the users want the visual appeal of the chart with the number right there and not have to look around or try to associate line 1 with line 1 from a text grid, etc...

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe like this?

stackedbar.png

Try a second expression with something like

=sum(total<Dim1> Value) & ' / '& num(sum({<Dim2={3}>} Value) / sum(total<Dim1> Value),'#,0%')

Disable 'bar' display option for that expression and enable 'values on data points' instead.

See attached sample.

Have fun,

Stefan

View solution in original post

52 Replies
Not applicable
Author

This isn't exactly what you are looking for, but it may help in the meantime. Put the formula for failure percentage as an expression and select 'Invisible'. Select 'Text as Pop-up'. The percentage will show when you hover over the selection. Here is an example.

whiteline
Master II
Master II

Hi

You can use dual() function for that.

For numeric part use your count expression and for text part - construct the desired string.

Not applicable
Author

Can you reply with a working example of this dual function in a chart expression? The help system only shows the dual function being utilized in a load script and that is not what we are asking for.

Anonymous
Not applicable
Author

In addition to the other ideas mentioned, a simple way is to just concatenate manually the expression to receive the percentage after the expression used for the count. So something like:

=count(field)&' / '&(sum(field/field)*100)&'%'

Not applicable
Author

Have you tested this solution to make sure that it will actually work?

==================================================

In addition to the other ideas mentioned, a simple way is to just concatenate manually the expression to receive the percentage after the expression used for the count. So something like:

=count(field)&' / '&(sum(field/field)*100)&'%'

Anonymous
Not applicable
Author

Yes, I did.

Have you?

Not applicable
Author

I modified my expression in my chart very simpy by adding a string to the end of it similar to what you propose...

My current expression is:

 

Sum ([Sample Count])

I modified it to simply be:

 

Sum ([Sample Count]) & 'XXXX'

And the result is my chart no longer display any data. I get the "No data to display", so I'm not sure how you made a stackable bar chart work with that expression you posted.

whiteline
Master II
Master II

Hi, bneumeier.

Sorry, I've tested dual() expression with bar chart and it works in many cases except stacked mode

You can easily test it yourself:

=dual('test ' & Count(YourValue), Count(YourValue))

But you can use 'text on axis' instead 'values on data points' if its suitable.

whiteline
Master II
Master II

Sum ([Sample Count]) & 'XXXX'  << its a string

You can't plot string value on numeric axis