S O'Dea
S O'Dea

Reputation: 21

Qlikview expression for percentage of bar (not total) in stacked bar chart

New to Qlikview, not yet familiar with scripting. My data has two dimensions, Month and HSETimes (4 categories), and the expression is Count(HSETimes). A stacked bar chart using relative values returns the percentage of the total by month by category.

I need an expression to return each months total as 100% with each category proportionately represented to produce a bar chart similar to the attached image, but I do not know how to write the expression: have tried many combinations of subset and total to no avail. Should be simple: can anyone help? ChartSample

Upvotes: 2

Views: 3229

Answers (1)

bdiamante
bdiamante

Reputation: 17550

Using the relative checkbox on a bar chart rarely results in the desired output. To accomplish what you want, uncheck the "Relative" checkbox, and modify your expression to explicitly calculate the percentage you want.

Dimensions: Month, Category

Expression: count(HSETimes) / count(total<Month> HSETimes)

Using total<Month> is part of the set modifier syntax and will result in your denominator being the total per month while your numerator will still be the count for each month and category.

Also, ensure you have the "stacked" bar type selected in the "style" menu and set your number format in the "Number" menu to show in percent.

See here for more info on set modifiers. Or you can google 'set analysis', 'total modifier', 'set modifiers' and that should help you find more info.

Upvotes: 1

Related Questions