Skip to main content
Announcements
YOUR OPINION MATTERS! Please take the Qlik Experience survey you received via email. Survey ends June 14.
cancel
Showing results for 
Search instead for 
Did you mean: 
vijetas42
Specialist
Specialist

Cumulative sum in bar chart

Hi All,

I need your suggestion so please help,

My scenario is like this,

I am having dataset like,

 

MonthSaleRolling 12
Month13
Month24
Month37
Month44
Month5422
Month6224
Month7125
Month8631
Month9940
Month101050
Month11454
Month12357
Month13259
Month14665
Month15772
Month16274

If my current month is Month16 then I want to show last 12 month data with cumulative sum considering from starting of month(Month1) I need to show data like column3 (Rolling 12) in bar chart.So what formula I should apply.

Thanks,

Vijeta

7 Replies
MayilVahanan

Hi

Try like this

LOAD *, Sale+ Alt(Peek('Roll'), 0) as Roll INLINE [

    Month, Sale, Rolling 12

    Month1, 3,

    Month2, 4,

    Month3, 7,

    Month4, 4,

    Month5, 4, 22

    Month6, 2, 24

    Month7, 1, 25

    Month8, 6, 31

    Month9, 9, 40

    Month10, 10, 50

    Month11, 4, 54

    Month12, 3, 57

    Month13, 2, 59

    Month14, 6, 65

    Month15, 7, 72

    Month16, 2, 74

];

Use Month as Dimension

Roll  as Expression

Result in table box:

Month Roll Rolling 12 Sale
Month133
Month274
Month3147
Month4184
Month522224
Month624242
Month725251
Month831316
Month940409
Month10505010
Month1154544
Month1257573
Month1359592
Month1465656
Month1572727
Month1674742
Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
vijetas42
Specialist
Specialist
Author

Thanks!

But, can we have any other option for not to do any changes in back end script and directly writing expression for Roll in Graph front end.

MayilVahanan

Hi

Refer this

Calculating rolling n-period totals, averages or other aggregations

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
qliksus
Specialist II
Specialist II

May be if you want to do this in Front End try something like this

Expression :  rangesum(above(sum(Sale),1,RowNo())) * sum({<Month={"=Monthnum>max(total Monthnum)-12"}>}1)

vijetas42
Specialist
Specialist
Author

Hi Thanks!

This expression showing correct value but, it only shows only last month bar not all the bars for 12 months,

sunny_talwar

Would you be able to share a sample where this isn't working?

qliksus
Specialist II
Specialist II

Hi ,

Have you created the Monthnum column and tried ? Your script should have something like that

LOAD *,num(PurgeChar(Month,'Month'),'00') as Monthnum INLINE [

    Month, Sale, Rolling 12

    Month1, 3,
    Month2, 4,
    Month3, 7,
    Month4, 4,
    Month5, 4, 22
    Month6, 2, 24
    Month7, 1, 25
    Month8, 6, 31
    Month9, 9, 40
    Month10, 10, 50
    Month11, 4, 54
    Month12, 3, 57
    Month13, 2, 59
    Month14, 6, 65
    Month15, 7, 72
    Month16, 2, 74

];

And then try the expression and let me know . Please check the attachment as well