Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to use a viarable to receive a field value

run the following script ,I get xx.qvd;

what's wrong with it ?

test:

load *;

select 2 as a,4 as b;

Concatenate

select 3 as a,5 as b;

let xx=max(FieldValue( 'a', 1 ));

let yy=max(FieldValue( 'b', 1 ));

if xx<yy then

store test into yy.qvd;

ELSE

store test into xx.qvd;

ENDIF;

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     If you need max and minimum value you need to do like this.

test:

LOAD 2 as a,4 as b AutoGenerate 1;

Concatenate

Load 3 as a,5 as b AutoGenerate 1;

tempMax:

Load Max(a) as Maxa,Max(b) as Maxb Resident test;

let xx=FieldValue( 'Maxa', 1 );

let yy=FieldValue( 'Maxb', 1 );

Drop table tempMax;

if xx<yy then

store test into yy.qvd;

ELSE

store test into xx.qvd;

ENDIF;

Celambarasan

View solution in original post

4 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     You should not use max for assigning to the variables.

     Change it like this

    

let xx=FieldValue( 'a', 1 );

let yy=FieldValue( 'b', 1 );

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     If you need max and minimum value you need to do like this.

test:

LOAD 2 as a,4 as b AutoGenerate 1;

Concatenate

Load 3 as a,5 as b AutoGenerate 1;

tempMax:

Load Max(a) as Maxa,Max(b) as Maxb Resident test;

let xx=FieldValue( 'Maxa', 1 );

let yy=FieldValue( 'Maxb', 1 );

Drop table tempMax;

if xx<yy then

store test into yy.qvd;

ELSE

store test into xx.qvd;

ENDIF;

Celambarasan

Jason_Michaelides
Partner - Master II
Partner - Master II

Also, you may need to call your variables with $...

test:

load *;

select 2 as a,4 as b;

Concatenate

select 3 as a,5 as b;

let xx=max(FieldValue( 'a', 1 ));

let yy=max(FieldValue( 'b', 1 ));

if $(xx)<$(yy) then

store test into yy.qvd;

ELSE

store test into xx.qvd;

ENDIF;

Hope this helps,

Jason

Not applicable
Author

Thanks all