
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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..
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try LET instead of SET ...
let me know

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
LET worked in loading the application with no errors but the data was not as expected.
PEEK worked perfectly.Thanks for your help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Anand.
Worked like a charm..
