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: 
reporting_neu
Creator III
Creator III

Peek doesn't works

Hi,

I would like to calculate a consumption.

For this, the line around the previous line must be subtracted.

To do this, I first loaded the data in order to then calculate the consumption.

 

NoConcatenate
TMP1:
LOAD
    Date(created) as created,
    Date(date#([ReferencePeriod],'MM/YYYY'), 'MM/YYYY') as ReferencePeriod,
    Number,
    MeterReading,
    Year(Date(date#([ReferencePeriod],'MM/YYYY'), 'YYYY')) as NYear,
    Month(Date(date#([ReferencePeriod],'MM/YYYY'), 'MM')) as NMonth
FROM [lib://FICILITY/MeterReading.xlsx]
(ooxml, embedded labels, table is Fernwaerme);


Qualify '*';

NoConcatenate
Fernwaerme:
Load * 
,   if(Number <> Peek(Number), MeterReading, MeterReading- Peek(MeterReading)) as Consumption
Resident TMP1
Order By Number, created, ReferencePeriodDESC;

Unqualify '*';

Drop Table TMP1;

 

The "Number" don't match for me even though they are identical. Doesn't matter if I use "upper(text())".

But only "MeterReading- Peek(MeterReading)) as Consumption" doesn't works, too.

What is wrong???

Labels (2)
1 Solution

Accepted Solutions
Chanty4u
MVP
MVP

Instead of peek have tried previous?

NoConcatenate

Fernwaerme:

Load * 

, if(Number <> Previous(Number), MeterReading, MeterReading - Previous(MeterReading)) as Consumption

Resident TMP1

Order By Number, created, ReferencePeriod DESC;

View solution in original post

2 Replies
Chanty4u
MVP
MVP

Instead of peek have tried previous?

NoConcatenate

Fernwaerme:

Load * 

, if(Number <> Previous(Number), MeterReading, MeterReading - Previous(MeterReading)) as Consumption

Resident TMP1

Order By Number, created, ReferencePeriod DESC;

reporting_neu
Creator III
Creator III
Author

With "previous" it works! Thanks very much!