Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
andrespa
Valued Contributor

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

1 Solution

Accepted Solutions

Re: Accumulated count in script

You might have more than one dimensions in there.... Try this

RangeSum(Above(TOTAL SessionCount, 0, RowNo(TOTAL)))

14 Replies

Re: Accumulated count in script

Try this

RangeSum(Peek('AccumulatedCount'), 1) as AccumulatedCount

andrespa
Valued Contributor

Re: Accumulated count in script

It doesn't work. The problem really is that you need to add 1 every single time the conditions fulfills (i.e. a simple a++ in any programming language) but here in the load editor you can't just do that. So I'm not sure if this is doable or you need to do it in the chart instead (although the same problem might happen there).

Not sure how to solve it.

Re: Accumulated count in script

You can, try this

If(StartDate < Previous(EndDate), RangeSum(Peek('AccumulatedCount'), 1), Peek('AccumulatedCount')) as AccumulatedCount

andrespa
Valued Contributor

Re: Accumulated count in script

That's exactly what I tried before. But something weird is happening or I'm missing something cause even in a table chart using the below expression and simplifying it without taking into account the date fields:

RangeSum(Above(SessionCount,0))

RangeSum.PNG

Which should work to gave me and accumulated value, it's just displaying always 1.

The same thing happens in the script if I use peek.

Re: Accumulated count in script

Not really, you have not used RowNo()

RangeSum(Above(SessionCount, 0, RowNo()))

andrespa
Valued Contributor

Re: Accumulated count in script

Indeed, you're right but still not working:

RangeSum.PNG

Re: Accumulated count in script

You might have more than one dimensions in there.... Try this

RangeSum(Above(TOTAL SessionCount, 0, RowNo(TOTAL)))

andrespa
Valued Contributor

Re: Accumulated count in script

Perfect! Didn't know you need to do that when you have more than 1 dimension. Thanks a lot, you've been very helpful!

Cheers,

Andrés

Re: Accumulated count in script

But this will continue to accumulate regardless of change in any of your dimensions.... if that is what you want, then that is great... else you will have to play around with your expression to make it to work