Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

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

View solution in original post

9 Replies
Anonymous
Not applicable
Author

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.

Anonymous
Not applicable
Author

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

MK_QSL
MVP
MVP

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;

Not applicable
Author

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.?

MK_QSL
MVP
MVP

Don't have idea except these two functions.... Peek and Previous

Not applicable
Author

Thanks Rudolf ,

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

Anonymous
Not applicable
Author

Gurjeet

Peek() & Previous() were designed specifically for usage like this and are easy to use.

There may or may not be another way to do the same, but why try and do it the hard way instead of the easy way.

Anonymous
Not applicable
Author

yes, you can use peek only with resident table

and no there is no other possibility to get the same result if you have to use variables

another approach would be to use the fields instead of variables. but that depends on your application

and might not be a solution in your case

maxgro
MVP
MVP

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'));