Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to calculate Cumulative total

I have attached the sample Qvw and the test file and I have to calculate the cumulative total.Can some one please help me here ?

I am having very hard time figuring it out.Thanks.

I have explained my requirement further in the qvw.

1 Solution

Accepted Solutions
sunny_talwar

Expanding your idea in the following example.

Script added:

LinkTable:

LOAD DISTINCT MonthYear as ReportYear,

  Date(If(AddMonths(MonthStart(YearEnd(MonthYear)), IterNo() - 12) <= MonthYear, AddMonths(MonthStart(YearEnd(MonthYear)), IterNo() - 12)), 'MMM-YY') as MonthYear,

  If(AddMonths(YearStart(MonthYear), IterNo() - 1) = MonthYear, 1) as Flag

Resident ProjectPipeline

While IterNo() <= 12;

Dim:

LOAD * Inline [

Dim

1

2

3

];



Capture.PNG

View solution in original post

6 Replies
Clever_Anjos
Employee
Employee

Use this technique: The As-Of Table

sunny_talwar

Expanding your idea in the following example.

Script added:

LinkTable:

LOAD DISTINCT MonthYear as ReportYear,

  Date(If(AddMonths(MonthStart(YearEnd(MonthYear)), IterNo() - 12) <= MonthYear, AddMonths(MonthStart(YearEnd(MonthYear)), IterNo() - 12)), 'MMM-YY') as MonthYear,

  If(AddMonths(YearStart(MonthYear), IterNo() - 1) = MonthYear, 1) as Flag

Resident ProjectPipeline

While IterNo() <= 12;

Dim:

LOAD * Inline [

Dim

1

2

3

];



Capture.PNG

Not applicable
Author

syou are the best stalwar1‌Thanks much,...appreciate your kindness and time !!

Not applicable
Author

Hi Sunny,  stalwar1

In this Cumulative total I am havinng an issue as my data file updated and additional months got added including 2017 months..so Total cumuulative is only adding up until Dec 16 .I want that to add on until all the existing months.How can I do that ?Any help is appreciated.

I have attached the sample file and the QVW.THANKS MUCH again.

Not applicable
Author

stalwar1‌ sorry to bother you.Any help is appreciated.Thanks much.

sunny_talwar

Check now:

ProjectPipeline:

LOAD

    Area,

    PPRegion,

    Market,

    Date(Date#(Trim(SubField(Header, Chr(10), 1)), 'MMM-YY'), 'MMM-YY') as MonthYear,

    Header as Header2,

    SubField(Header, Chr(10), 2) as Header,

    Value

Resident Table;

Left Join (ProjectPipeline)

LOAD Min(MonthYear) as Min_MonthYear

Resident ProjectPipeline;

DROP Table Table;

LinkTable:

LOAD DISTINCT MonthYear as ReportYear,

  Date(AddMonths(MonthYear, IterNo() - ((Year(MonthYear) * 12 + Month(MonthYear)) - (Year(Min_MonthYear) * 12 + Month(Min_MonthYear)))), 'MMM-YY') as MonthYear,

  If(AddMonths(MonthYear, IterNo() - ((Year(MonthYear) * 12 + Month(MonthYear)) - (Year(Min_MonthYear) * 12 + Month(Min_MonthYear)))) = MonthYear, 1) as Flag

Resident ProjectPipeline

While IterNo() <= ((Year(MonthYear) * 12 + Month(MonthYear)) - (Year(Min_MonthYear) * 12 + Month(Min_MonthYear)));