Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to Show Stacked Bar Chart as Percentage?

Hi all,

I'm trying to make a stacked bar chart that shows the "mixes" of certain items, relative to the whole.  The graph below is 80% of the answer I want, but the percentages aren't all adding up to 100.  It's showing percentages of the most recent data point. 

graph.png

Basically, I'd like all of the bars to be the same length, and show percentages in them.  This way we can see how the "mixes" of these items change over time. 

The expression is one used to calculate inventory whereby it counts Arrivals and subtracts Sales up until a certain date (I'm showing inventory). 

COUNT({$<DateType={'Arrival'}>} OrderLineID) - COUNT({$<DateType={'Sale'}>} OrderLineID)

This links to a Date Bridge table that looks like the following:

Untitled picture.png

I think I'm really close to achieving what I'm looking for, but I just need to know that one extra step. 

Thank you very much for any and all help!

11 Replies
sunny_talwar

In that case you can first try this expression without any scripting changes:

=(RangeSum(Above(TOTAL (Count({$<DateType={'Arrival'}>} OrderLineID)), 0, RowNo(TOTAL))) - RangeSum(Above(TOTAL (Count({$<DateType={'Sale'}>} OrderLineID)), 0, RowNo(TOTAL))))/

Sum(TOTAL <Date>Aggr(RangeSum(Above(TOTAL (Count({$<DateType={'Arrival'}>} OrderLineID)), 0, RowNo(TOTAL))) - RangeSum(Above(TOTAL (Count({$<DateType={'Sale'}>} OrderLineID)), 0, RowNo(TOTAL))), Date, Dim))

But in case it doesn't work, then you will need to sort Date in Ascending order.

Not applicable
Author

Hi Sunny, I've implemented the above code as my expression, and it gave me the following results:

Untitled picture.png