Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
travi
Contributor
Contributor

How to show percentage in all blocks of bar chart, where sum of each column should be 100%?

I have a stacked bar chart, with years as dimensions and the expression sum(Amount) / sum( Number) and want to express this as a %. I enabled 'Plot Values inside Segments' on the Presentation Tab and set it to show relative. The problem here is it shows the value of each block as a % of all the blocks, whereas I need it to show as a % of the respective column. I think a solution in the script cannot be used as it has to be dynamic to selections (which are many).

Ex: In the image, the value for 2018 shows 16.51%, whereas i want it to show 100%. For 2019, it shows 18.4% and 16.6%, which sums to 35.1%,  but I want it to sum to 100%.

travi_0-1648204245860.png

 

Any ideas to help resolve this is appreciated! 

1 Reply
QFabian
Specialist III
Specialist III

Hi @travi , here an example , please check if it works for you :

Test script :

LOAD * INLINE [
Amount, Number, Year, Dim2
23, 2, 2018, a
34, 3, 2018, a
45, 4, 2018, b
56, 5, 2018, b
67, 6, 2019, a
78, 7, 2019, b
534, 8, 2019, c
87, 7, 2020, a
654, 6, 2020, b
443, 5, 2020, c
43, 4, 2020, d
];

chart expression :

Sum (Amount) / Sum ( total <Year>Amount)

Chart result :

QFabian_0-1648502242626.png

QVW attached below.

 

QFabian