7 Replies Latest reply: Dec 2, 2016 11:45 AM by Eduardo DImperio RSS

    Variable don't recognized inside a IF

    Eduardo DImperio

      Hi,

       

      Im new in qlik sense and i have a little problem with this code below:

       

      Set dia=0;

      Do while dia<=2   

         

      left join (ANALISE_TMP)

       

       

      LOAD

        OID_METER,

          VALUE_READ*TYPE_CONSTANT AS CONSUMODIA$(dia),

          PEEK(VALUE_READ)*TYPE_CONSTANT AS CONSUMO_ANTERIOR_DIA$(dia),

          IF (OID_METER=PEEK(OID_METER),

              CONSUMODIA$(dia)-CONSUMO_ANTERIOR_DIA$(dia)) AS CONSUMO_REAL$(dia)

      RESIDENT TMP2

      where FLOOR(DATE_READ)=FLOOR(TODAY()-$(dia))

      ORDER BY OID_METER,DATE_READ DESC;

      Let dia=dia+1;

      LooP

       

      For some reason qlik sense understant my loop, create the variable CONSUMODIA0, but give me error :

       

      Field not found - <CONSUMODIA0>

      O erro ocorreu aqui:

      left join (ANALISE_TMP) LOAD OID_METER, VALUE_READ*TYPE_CONSTANT AS CONSUMODIA0, PEEK(VALUE_READ)*TYPE_CONSTANT AS CONSUMO_ANTERIOR_DIA0, IF (OID_METER=PEEK(OID_METER), CONSUMODIA0-CONSUMO_ANTERIOR_DIA0) AS CONSUMO_REAL0 RESIDENT TMP2 where FLOOR(DATE_READ)=FLOOR(TODAY()-0) ORDER BY OID_METER,DATE_READ DESC

       

      Some help please