9 Replies Latest reply: Sep 2, 2014 9:16 AM by Massimo Grossi RSS

    num(date)

      Data:

      LOAD EMPNO,

          ENAME,

          JOB,

          MGR,

          HIREDATE,

      //    max(HIREDATE) as maxDate,

          SAL,

          COMM,

          DEPTNO,

          "DATE_UPDATED";

      SQL SELECT *

      FROM SCOTT.EMP;

       

       

      Mindate:

      load    min(date(HIREDATE,'DD-MMM-YYYY')) as minDate, max(date(HIREDATE,'DD-MMM-YYYY')) as maxDate  Resident Data;

       

       

      LET vMinDate = num(Peek('minDate'));

       

      LET vMaxDate = num(Peek('maxDate'));

       

       

      //Let Vchk = num(peek('maxDate'));

      Let Vchk = num('maxDate');

       

       

       

      I have mindate and maxdate from a table, i need to convert them to a number using num() function in qlikview.

       

      what i observe that vMinDate and vMaxDate are working fine while they use peek() before num().


      and Vchk, if i  use num() without peek() , the variable doesn't show any value.


      I dont understand what the logic behind this.


      thanks

        • Re: num(date)
          Bill Markham

          Fields MinDate and MaxDate are in the table Mindate you created.

           

          Hence you need an Inter Record Function such as Peek() to read the data in a script.

          • Re: num(date)
            Rudolf Linder

            I hope I understood your question correct:

             

            you have a table with one and you want the content of this row assigned to a variable

            in qlikview there is only one way to to this:

             

            you must assign the content of a table using peek, even if there is only one row in it

            so by default, peek, takes the last row (which in your case is okay)

             

            so using Let Vchk = num('minDate') does not know what to assign and therefor returns null

             

            I hope I could clarify it a little bit

            • Re: num(date)
              Manish Kachhia

              Data:

              LOAD EMPNO,

                  ENAME,

                  JOB,

                  MGR,

                  HIREDATE,

                  SAL,

                  COMM,

                  DEPTNO,

                  "DATE_UPDATED";

              SQL SELECT *

              FROM SCOTT.EMP;


              MinMaxDate:

              Load

                Min(HIREDATE) as MinDate,

                Max(HIREDATE) as MaxDate

              Resident Data;

               

               

              Let vMinDate = NUM(PEEK('MinDate',0,'MinMaxDate'));

              Let vMaxDate = NUM(PEEK('MaxDate',0,'MinMaxDate'));

               

               

              Drop Table MinMaxDate;

              • Re: num(date)

                ok thanks BILL/RUDOLF

                 

                we can use peek() and previous() for the table, when case is we are loading data from RAM i.e. resident load.

                 

                Am i right.

                 

                Is there any another approach, or function that we can use instead of peek/previous.?

                • Re: num(date)

                  Thanks Rudolf ,

                   

                  u specify in your answer that .. here is only one way

                   

                   

                   

                  • Re: num(date)
                    Massimo Grossi

                    Data:

                    SQL SELECT

                    min(HIREDATE) "minDate",

                    max(HIREDATE) "maxDate"

                    FROM SCOTT.EMP;

                     

                    // peek to get the value from field minDate and maxDate

                    Let vMinDate = num(Peek('minDate'));

                    Let vMaxDate = num(Peek('maxDate'));