Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
eduardo_dimperio
Specialist II
Specialist II

HELP WITH PEEK()

Hi everyone,

I dont understand why my peek sometimes get strange numbers

In this case appears a number that duplicated and some number off order.

any help please.

Corrige_Medidor:

LOAD

DISTINCT

OID_METER,

VALUE_READ AS VALOR,

DATA,

TEMPO

RESIDENT TMP2

ORDER BY OID_METER,DATA,TEMPO DESC;

NoConcatenate

Teste_Medidor:

LOAD

OID_METER,

VALOR,

DATA,

TEMPO,

peek(VALOR),

peek(VALOR)- VALOR AS DIFERENCA

RESIDENT Corrige_Medidor

ORDER BY OID_METER,DATA,TEMPO DESC;

drop table Corrige_Medidor;

Data_Erro.JPG

1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

is your table also sorted by in the same order as the orderby clause?

OID_METER,DATA,TEMPO DESC;


try with Previous(Valor) instead of Peek()

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

4 Replies
vinieme12
Champion III
Champion III

is your table also sorted by in the same order as the orderby clause?

OID_METER,DATA,TEMPO DESC;


try with Previous(Valor) instead of Peek()

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Eduardo,

it's a bit hard to troubleshoot your app without seeing it, but here is what I think is happening:

1. Your never verify that OID_METER remains the same from the previous records. So, you might be picking up the values of peek(VALOR) from the previous meter ID. In order to avoid that, your formula should be:

IF(Peek(OID_METER) = OID_METER, peek(VALOR), null()) as [Last VALOR]

2. Your data is sorted by OID, Date, and Time (in descending order), but your data in the screenshot is not sorted by Time, hence the "previous" values look confusing. If you sort your table on the screen the same way you sorted your data, it will look less confusing.

If you need a deeper analysis, please post a sample of your App.

cheers,

Upgrade your Qlik skills at the Masters Summit for Qlik - coming soon to Munich, Germany and Boston, MA!

eduardo_dimperio
Specialist II
Specialist II
Author

Hi Vinneth,

Get the same problem, and i dont know how to check if my table is sorted by OID_METER,DATA,TEMPO DESC

eduardo_dimperio
Specialist II
Specialist II
Author

Hi Vinneth,

That was my mistake, i checked on internet how to order by my table and when i did that the results match.

Thank you very much