Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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
hrlinder
Honored Contributor

Re: num(date)

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

9 Replies

Re: num(date)

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.

hrlinder
Honored Contributor

Re: num(date)

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

MVP
MVP

Re: num(date)

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

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

MVP
MVP

Re: num(date)

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

Not applicable

Re: num(date)

Thanks Rudolf ,

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

Re: num(date)

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.

hrlinder
Honored Contributor

Re: num(date)

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

MVP
MVP

Re: num(date)

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

Community Browser