4 Replies Latest reply: Feb 7, 2017 11:17 AM by Eduardo DImperio RSS

    HELP WITH PEEK()

    Eduardo DImperio

      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

        • Re: HELP WITH PEEK()
          Vineeth Pujari

          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()

          • Re: HELP WITH PEEK()
            Oleg Troyansky

            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!