Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I'm having trouble getting Previous and Peek to work on a simple data set.
I'm trying to get the cumulative Minutes in the production plan as a start.
But for some reason the extract I get seems to stop cumulating after the 2nd row!
Red is what Qlik is giving me at present, green is what I'm after.
Any help appreciated.
Steve
PlanTMP:
LOAD
Machine,
timestamp("Sched. start") as "Sched. start",
Plan_Minutes
FROM [lib://QLIK-DATA/CSV/INJECTION.csv]
(txt, codepage is 28591, embedded labels, delimiter is ',', msq) ;
Plan:
Load
*,
if(previous(Machine)<>Machine,Plan_Minutes,peek(Plan_Minutes)+Plan_Minutes) as [Machine Check],
if(previous(Machine)=Machine,peek(Plan_Minutes)+Plan_Minutes,Plan_Minutes) as Cumulative
Resident PlanTMP Order by Machine,"Sched. start" asc;
DROP Table PlanTMP;
Hi, you need to add the the previous cumulative, not the plan_minutes:
if(previous(Machine)=Machine,peek(Cumulative)+Plan_Minutes,Plan_Minutes) as Cumulative
I also use Rangesum() that converts Nulls to zero:
if(previous(Machine)=Machine,Rangesum(peek(Cumulative),Plan_Minutes),Plan_Minutes) as Cumulative