Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

abhi251983
New Contributor II

Showing percentages in stack bar chart for each stack that is relative to that total bar

Hi All,

I'm facing an issue with the Stack bar chart where I want to show the % for each stack that is relative to the entire bar. I mean if I've 4 stacks in one bar, then I want to show 25% in each stack.

Thanks in advance for your help!!!

9 Replies
Not applicable

Re: Showing percentages in stack bar chart for each stack that is relative to that total bar

I believe, Use the Total Qualifier in the expression

Sum(Sales) / Sum(TOTAL <DIM1> Sales)

Not applicable

Re: Showing percentages in stack bar chart for each stack that is relative to that total bar

If not working please post sample qvw.

abhi251983
New Contributor II

Re: Showing percentages in stack bar chart for each stack that is relative to that total bar

Hey Thanks,

Actually after posting the question, I figured out the answer by looking at this post Re: showing values in % but after this bar has changed to 100% stacked bar chart. Is it something can we avoid, I mean we can use the stack bar chart as per the real values but when showing the values in the stacks, then it should show the %.

Thanks!!!

Employee
Employee

Re: Re: Showing percentages in stack bar chart for each stack that is relative to that total bar

Does the attach help ?

Not applicable

Re: Showing percentages in stack bar chart for each stack that is relative to that total bar

Can you attach the qvw?

Re: Showing percentages in stack bar chart for each stack that is relative to that total bar

Hi, you can use Dual function to split the value that defines the high of the bar, and the value shown:

Dual(Sum(Sales), Num(Sum(Sales) / Sum(TOTAL <DIM1> Sales), '#.##0,00%')

Probably you need to set 'Predefined Expression' in Numbers tab

Not applicable

Re: Showing percentages in stack bar chart for each stack that is relative to that total bar

Hi Ruben !

How if i have many dimensions ? By what can i replace DIM1 in your exemple in ordrer to make it bynamic ?

Thank you for your response

Am'

Re: Showing percentages in stack bar chart for each stack that is relative to that total bar

You can replace DIM1 by your chart expressions, ie:

<DIM1, DIM2...>

To make it dynamic you can create a variable that returns the dimensions string and use this variable, ie:

variable vDimensions = =If(GetSelected...  or =Concat(DimensionSelector, ', ')

// something that returns you the string with dimensions, depens on your model and how works your dynamic chart.

Then use the variable:

Dual(Sum(Sales), Num(Sum(Sales) / Sum(TOTAL <$(vDimensions)> Sales), '#.##0,00%')

Not applicable

Re: Showing percentages in stack bar chart for each stack that is relative to that total bar

Thank you !!

Community Browser