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

assign field values into a variable

Hi all,

Can we place in a variable with the field of distinct values in edit script load ?

Ex: Consider the in my table having FieldA and having values in it are 5

FieldA

1

1

2

3

4

Now i needs to have my variable vVar1 = 1,2,3,4

Thanks in advance.


8 Replies
sivarajs
Specialist II
Specialist II

Try this

set vVar='Fieldname';

Concat($(vVar),',')

Not applicable
Author

Hi Sivaraj, thanks for your response. But concat function will not work in edit script.

Below scritp what i'm trying in my original project

If(vStep = 0) then

//Initial Load

Tab1:

LOAD  CaptureDateTime

FROM

[..\QVD\4Weeks\EAT_20121029.qvd]

(qvd);

Let vVar = CaptureDateTiem;

ELSE

//Incremental Load

Tab1:

LOAD  CaptureDateTime

FROM

[..\QVD\4Weeks\EAT_20121029.qvd]

(qvd) Where not Exists($(vVar));

ENDIF

I hope you might got what i'm looking for ?

Thanks in advance.

sivarajs
Specialist II
Specialist II

Concat works in script,am little confused with your script logic

Not applicable
Author

Sorry,Yes Concat function is working in Edit Script.

I tried below script but not holding any values in vVar variable, just displays empty in vVar.

Tab1:

LOAD * Inline

[CaptureDateTime

1

1

2

3];

let noRows = NoOfRows('Tab1')-1;

for i=0 to $(noRows)

    let vVar =Concat(peek('CaptureDateTime',$(i),'Tab1'),','); 

next

Please let me know what is the wrong in this.

Thanks in advance

sivarajs
Specialist II
Specialist II

Use this

Tab1:

LOAD * Inline [

CaptureDateTime

1

1

2

3

5];

let noRows = NoOfRows('Tab1')-1;

for i=0 to $(noRows)

   let vVar=FieldValue('CaptureDateTime',$(i));

LOAD * ,'$(vVar)' as Field1

Resident Tab1;

   next i

In where clause use Field1 instead of variable

This might help for you

Not applicable
Author

Hi,

Please have a look at the Qlikview Components:

http://code.google.com/p/qlikview-components/

Especially Qvc.PopulateVariables

That will do all of the above, but then a lot cleaner.

Kind Regards,

Dion

jeffmartins
Partner - Creator II
Partner - Creator II

Hi venkatveer,

you can solve this using the concat function with a temporary table and then the peek function to assign the field value to the vVar1 variable.

See the attached file.

Regards

michaelfreitas
Creator
Creator

Jefferson Martins correctly answered your question.

Adding:

In the stretch :let vVar1 = peek ( ' FIELDA ', 0 , ' tmp ');


..if the name FIELDA field is with space, [ Field A] inform without symbols [ ] , example :

let vVar1 = peek ( 'Field A', 0 , ' tmp ');