Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

maelafifi
New Contributor III

Bar chart with bar percent relative to entire chart

Hi Qlik community!

I have a bar graph that currently displays the counts of incidents. I also have a custom toggle, that when clicked, changes the KPI's on the sheet to a percentage, instead of a count. I want to implement this on a bar graph, but I am having an issue summing up all the values within the bar graph itself. Here is a picture of the current bar graph:

EHS_Snippet.PNG

As you can see, the totals of the bars above add up to 42. So when I click the percentage toggle (not shown here), for the first bar at the top I expect to see 10/42*100 which would amount to 23.8 percent. However, I am getting 10/10 which is understandable because it is only counting the total for that dimension/measure combo.

So, does anyone know a calculation that will sum up the values from the entire bar chart, so that I can be able to divide by it to produce a percentage upon toggling?

Any help will be much appreciated!

Mohamed

EDIT/NOTE: The number needs to be dynamic, so I cannot create a static variable!

1 Solution

Accepted Solutions
maelafifi
New Contributor III

Re: Bar chart with bar percent relative to entire chart

This was a lot simpler than I expected it to be and it took me too long to figure it out.

Simple: sum(amount) /sum(total amount)

4 Replies
isingh30
Contributor III

Re: Bar chart with bar percent relative to entire chart

Can you share your sample application ?

maelafifi
New Contributor III

Re: Bar chart with bar percent relative to entire chart

I cannot, unfortunately, as I am working with customer-sensitive production data. The bar chart consists of one dimension and two measures. The two measures are simply distinct counts of two different event types.

EHS_Snippet2.PNG

Please let me know if there is any more information you might need to better help with this.

Thanks,

Mohamed

maelafifi
New Contributor III

Re: Bar chart with bar percent relative to entire chart

This was a lot simpler than I expected it to be and it took me too long to figure it out.

Simple: sum(amount) /sum(total amount)

vhayward
New Contributor III

Re: Bar chart with bar percent relative to entire chart

Well yes if you want to have it on a total of all values of the dimension.

But if you want to know the share per dimension value:

sum(amount) /sum(total <dimension> amount)