Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Setting and using variables

Hi All,

I am new to QlikView and am stuck with an issue in the script side.

I need to create a variable and store a value, only to be used by the next LOAD statement.

Here is how it goes.

FACT:

LOAD fields from FACT.qvd;

SET CYEAR=FACT.FISCAL_YEAR;

DIM:

IF($(CYEAR)-DIM.FISCAL_YEAR=0,DIM.FISCAL_WEEK,0)

FROM DIM.qvd;

The issue is that the $(CYEAR) is replaced by FACT.FISCAL_YEAR when the application is refreshed. And it pops up an error message that the field is not found.

Thanks for your help..

1 Solution

Accepted Solutions
its_anandrjs

Hi,

For load value from any table use Peek() and for storing use LET rather than SET

FACT:

LOAD fields from FACT.qvd;

LET CYEAR = Peek('FACT.FISCAL_YEAR',-1,'FACT');

DIM:

IF($(CYEAR)-DIM.FISCAL_YEAR=0,DIM.FISCAL_WEEK,0)

FROM DIM.qvd;

Note:- And what value you need in the variable CYEAR i suppose max year if the order of table is ascending then you get max year value, otherwise provide sample file.

Regards

Anand

View solution in original post

4 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Try LET instead of SET ...

let me know

its_anandrjs

Hi,

For load value from any table use Peek() and for storing use LET rather than SET

FACT:

LOAD fields from FACT.qvd;

LET CYEAR = Peek('FACT.FISCAL_YEAR',-1,'FACT');

DIM:

IF($(CYEAR)-DIM.FISCAL_YEAR=0,DIM.FISCAL_WEEK,0)

FROM DIM.qvd;

Note:- And what value you need in the variable CYEAR i suppose max year if the order of table is ascending then you get max year value, otherwise provide sample file.

Regards

Anand

Not applicable
Author

LET worked in loading the application with no errors but the data was not as expected.

PEEK worked perfectly.Thanks for your help.

Not applicable
Author

Thanks Anand.

Worked like a charm..