Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Sokkorn
Master
Master

How to create variable to get all field value from load?

Hi All,

I have load script as below:

[tmpDate]:
LOAD * INLINE
[DateField,
'01-06-2011',
'02-06-2011',
'03-06-2011'];

What I want is var1='01-06-2011','02-06-2011','03-06-2011'

How can I do this?

Please help to add script.

Thanks in advanced!

Best Regards,

Sokkorn Cheav

1 Solution

Accepted Solutions
nagaiank
Specialist III
Specialist III

You may try the following script also to get the values between single quotes.

[tmpDate]:

LOAD Chr(39) & DateField & Chr(39) as DateField,'x' as Grp;

LOAD * INLINE

[DateField,

'01-06-2011',

'02-06-2011',

'03-06-2011'];

Temp:

LOAD Grp, Concat(DateField,',') as var Resident tmpDate Group By Grp;

LET var = Peek('var',0,Temp);

DROP Table Temp;

Hope this helps.

View solution in original post

5 Replies
Not applicable

=Concat(DateField,',')

Hope this helps

Sokkorn
Master
Master
Author

Hi Dihuibao,

Thanks for your reply. After load data with your script, it require Group By. Can you add more detail on this.

Note: What I want is var1='01-06-2011','02-06-2011','03-06-2011'

Many thanks

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi

   Here is an example.

   Try below code - Replace field name with your data fields.

  

Directory;

LOAD [Customer Name]

FROM

[..\My Documents\Downloads\TestData.xls]

(biff, embedded labels, table is Sheet1$);

let count  = FieldValueCount('Customer Name');

set var = '1';

for i=1 to $(count)

if '$(var)' = 1 then

   let var = FieldValue('Customer Name',$(i));

ELSE

   let var = '$(var)' & ','& FieldValue('Customer Name',$(i)); 

end if

Next  

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
nagaiank
Specialist III
Specialist III

You may try the following script also to get the values between single quotes.

[tmpDate]:

LOAD Chr(39) & DateField & Chr(39) as DateField,'x' as Grp;

LOAD * INLINE

[DateField,

'01-06-2011',

'02-06-2011',

'03-06-2011'];

Temp:

LOAD Grp, Concat(DateField,',') as var Resident tmpDate Group By Grp;

LET var = Peek('var',0,Temp);

DROP Table Temp;

Hope this helps.

Sokkorn
Master
Master
Author

Thanks Krishnamoorthy.