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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
andrespa
Specialist
Specialist

Accumulated count in script

Hi All, I need to do something it may be simple but so far I'm no able to get it. So basically what I want is illustrated in the "AccumulatedCount" column below:

KeyStartDateEndDateCountAccumulatedCount
110/02/201812/02/201811
311/02/201813/02/201812
412/02/201814/02/201813
513/02/201815/02/201814
514/02/201816/02/201815

The closest shoot I got so far is use this expression:

if(StartDate< Previous(EndDate), Count+1, Previous(Count))           AS  AccumulatedCount


But, of course that's not what I want cause I'm summing 1 to 1 all the time:


KeyStartDateEndDateCountAccumulatedCount
110/02/201812/02/201811
311/02/201813/02/201812
412/02/201814/02/201812
513/02/201815/02/201812
514/02/201816/02/201812

So I need something like that expression but over the AccumulatedCount field but not sure how to do it. Hope it makes sense.

Cheers,

Andrés

14 Replies
andrespa
Specialist
Specialist
Author

Although if I tried to applied the date logic to it or put it into the script I fail miserably:

if([Session Start]< Above([Session End]), RangeSum(Above(TOTAL SessionCount,0, RowNo(TOTAL))), Above(SessionCount)) // Chart Not working

if([Session Start]< Previous([Session End]), RangeSum(Peek(SessionCount,0, RowNo())), Peek(SessionCount)) AS RollingSessionCount  // Script Not working

andrespa
Specialist
Specialist
Author

Yes, indeed that's not what I really want, but it's a step forward. I'll try to figure it out playing around yest.

sunny_talwar

May be provide few rows of data where the condition is met and where the condition isn't met and then share the output you expect to see from it?

andrespa
Specialist
Specialist
Author

Sure, this is an xlsx sample file and the image below explains what I want:

AccumulatedCount.PNG

Hope it makes sense

sunny_talwar

Try this

Table:

LOAD StartDate,

    EndDate,

    Session

FROM

[..\..\Downloads\AccumulatedCount.xlsx]

(ooxml, embedded labels, table is Sheet1);


FinalTable:

LOAD *,

If(StartDate <= Previous(EndDate), RangeSum(Peek('Accu'), Session), Alt(Peek('Accu'), Session)) as Accu

Resident Table

Order By StartDate;


DROP Table Table;