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: 
Anonymous
Not applicable

sum in the load statement ... need some help

Hi all,

In the LOAD statement I want to sum a RepeatCounter for each row looking back 6 months ...

For each row I need a sum of the following:

The Orderdate of the lookup records should be between Orderdate of the current row and Orderdate - 6 months
and the SerialNumber should also be the same ... (this indicates there is a repeated repair which we want to count)

I already have some counters which I created, but this is the last counter needed ... and I can't find a good solution.

RepeatRepair:
LOAD *,
IF (
(SerialNumber = previous (SerialNumber)) and
Serviceordernr <> previous(Serviceordernr) and
(addmonths(Orderdate, -6) < previous (Orderdate)),
1,0) as RepeatCounter
;
LOAD
Serviceordernr,
SerialNumber,
Orderdate
RESIDENT RepeatRepairTemp
ORDER BY SerialNumber, Orderdate, Serviceordernr;


JOIN
LOAD *,
IF (
(SerialNumber = previous (SerialNumber)) and
Serviceordernr <> previous(Serviceordernr) and
(addmonths(Orderdate , -6) < previous (Orderdate )),
1,0) as RepeatCounter_repeatedSO
;
LOAD
Serviceordernr,
SerialNumber,
Orderdatum
RESIDENT RepeatRepairTemp
ORDER BY SerialNumber, Orderdate DESC, Serviceordernr DESC;


Anyone has suggestions on how to do this?? Is there a way of using a while loop??

thx

Anita

0 Replies