Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
roee1983
Contributor III
Contributor III

PEEK FUNCTION

HI All,

I have a question  regarding  Peek Function.

I have the following table:

Name     B        C     D   

XXX         1        2       3

-               4         5      6

-                7        8      9

-               10      11    12

-                13     14    15

-               16      17    18

I tried the following :

IF(ISNULL(NAME),PEEK('NAME',1)) AS NEW_NAME,

It doesn't work!

I want all records would get XXX

Please Help..

Thanks

1 Solution

Accepted Solutions
JonnyPoole
Former Employee
Former Employee

i took the peek() out of the load and used a variable instead and a resident load. should be just as fast. the first load only loads the first record to get the variable name. !

first 1;

Data:

LOAD Name,

    B,

    C

FROM

(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);

let vName=peek('Name',0,'Data');

drop table Data;

Data:

load

  *,

  if(  Name = '','$(vName)',Name) as NewName

FROM

(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);

View solution in original post

8 Replies
MarcoWedel

IF(Len(NAME),NAME,PEEK(NAME)) AS NAME

roee1983
Contributor III
Contributor III
Author

Hi Marco,

Thanks for responding , I tried it but still I get only one record for XXX.

I need XXX will get all values for all records.

Thanks

roee1983
Contributor III
Contributor III
Author

Hi,

I need to get :

NAME  B  C  D

XXX     1   2   3

XXX     4    5   6

XXX     7   8    9

XXX    10   11  12

XXX    13   14  15

Thanks

JonnyPoole
Former Employee
Former Employee

i took the peek() out of the load and used a variable instead and a resident load. should be just as fast. the first load only loads the first record to get the variable name. !

first 1;

Data:

LOAD Name,

    B,

    C

FROM

(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);

let vName=peek('Name',0,'Data');

drop table Data;

Data:

load

  *,

  if(  Name = '','$(vName)',Name) as NewName

FROM

(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);

nagaiank
Specialist III
Specialist III

The following script using Peek() works.

LOAD RowNo() as ID,* Inline [
Name,B,C,D   
XXX,1,2,3
,4,5,6
,7,8,9
,10,11,12
,13,14,15
,16,17,18
]
;
B:
NoConcatenate LOAD ID
   ,
If(Len(Trim(Name))=0,Peek(Name),Name) as Name,B,C,D
  
Resident A Order By ID;
DROP Field ID From B;
Drop Table A;

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

That should be

PEEK('NAME',0))

to get the first row. For peek() function, first row is "0".

-Rob

http://masterssummit.com

MarcoWedel

Hi,

seems to work for me:

QlikCommunity_Thread_131302_Pic1.JPG.jpg

LOAD IF(Len(Name),Name,PEEK(Name)) AS Name,

    B, C, D

INLINE [

    Name, B, C, D

    XXX, 1, 2, 3

    , 4, 5, 6

    , 7, 8, 9

    , 10, 11, 12

    , 13, 14, 15

    , 16, 17, 18

];

Are those missing Names empty values, or are they realy '-' characters?

hope this helps

regards

Marco

JonnyPoole
Former Employee
Former Employee

for what its worth i think they were empty strings    Name=''  .  I tried with null checking off the data set but it didn't catch anything until i used empty strings.  Probably best to check for empty strings and nulls

if(  Name = ''  or isnull(Name)=-1 ,   < missingornullvalue> , regularvalue)