Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to calculate yearly cumulative totals in bar chart

I want to show the cumulative totals by year in a bar chart. I used full accumulation in expressions tab but its accumulating all values and giving totals by month. Assue my data set have quantity 10 for each month. I want to show cumulative totals by year like below. is there any easy way to achieve this?

Bar Chart is accumulating totals like below:

error loading image

I want to see below result in bar chart.

Month-YearSales

Jan-2010

10

Feb-2010

20
Mar-201030
Apr-201040
May-201050
Jun-201060
July-201070
Aug-201080
Sep-201090
Oct-2010100
Nov-2010110
Dec-2010120
Jan-201110
Feb-201120
6 Replies
johnw
Champion III
Champion III

Attached are two approaches.

The first uses an AsOf table to connect each month to all of the months YTD. That lets you do a simple sum(Sales) with no chart accumulation, and the data model itself handles the accumulation. That's the approach I suggest since it doesn't depend on how the chart is sorted and what values are selected.

Months:
LOAD date(fieldvalue('Month',iterno())) as Month
AUTOGENERATE 1
WHILE len(fieldvalue('Month',iterno()))
;
AsOfMonth:
LOAD
Month as AsOfMonth
,date(addmonths(Month,1-iterno()),'MMM-YYYY') as Month
RESIDENT Months
WHILE iterno() <= month(Month)
;
DROP TABLE Months;

But a much simpler approach that may be good enough in some cases is this:

rangesum(above(sum(Sales),0,month(Month)))

Not applicable
Author

Thank you verymuch it worked.

Not applicable
Author

John, i was following the second method. But my fiscal year starts from august not jan. in that case above function not giving correct results. Could you suggest any solution for this?

johnw
Champion III
Champion III

I think this?

rangesum(above(sum(Sales),0,mod(month(Month)+4,12)+1))

Not applicable
Author

Great. It worked fine Yes thank you .

Not applicable
Author

Hello Sir,

Attached is the Graph i'm looking to create,

the problem is to show the single bar graph with different colors each representing the new amt added.

Regards