Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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);
IF(Len(NAME),NAME,PEEK(NAME)) AS NAME
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
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
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);
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;
That should be
PEEK('NAME',0))
to get the first row. For peek() function, first row is "0".
-Rob
Hi,
seems to work for me:
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
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)