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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Loading a Variable with an integer

Hi all

In my script I am loading a table 'tblSubList' but I am not interested in every record in this table, and loading every record adds time to the script.

Earlier in the script I have another table 'tblCHI' that contains the ID numbers for the records I am interested in.

Can I take the minimum ID from 'tblCHI' and use this in the WHERE clause for 'tblSubList'?  Or would a Left Join be just as efficient (as there may not be matching records in 'tblSubList').

In SQL Server I would do something like

@MinSysID = SELECT Min(SYS_ID) FROM tblCHI

SELECT * FROM tblSubList WHERE SYS_ID >= @MinSysID

Can a similar thing be done in QlikView?

Labels (1)
4 Replies
Clever_Anjos
Support
Support

Tmp:

SQL SELECT Min(SYS_ID) as min FROM tblCHI;

Let vMin=peek('min');

drop table Tmp;

SQL SELECT * FROM tblSubList WHERE SYS_ID >= $(vMin)

alexandros17
Partner - Champion III
Partner - Champion III

Yes, use the keyword EXISTS, in this way you can load only existing IDs previously loaded

Hope it helps

Nicole-Smith
MVP
MVP

For tblSubList, you should be able to use a WHERE clause like:

WHERE exists(IDFromtblCHI, IDFromtblSubList)

richard
Partner - Creator
Partner - Creator

Hello James,

The Qlikview equivalent way to approach this is by using the PEEK function.

E.g. peek(fieldname [ , row [ , tablename ] ] )

As in SQL you can put the result in a variable and the use that variable in the where clause of the tblSubList table.