Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join this live chat April 6, 10AM EST - QlikView to Qlik Sense REGISTER
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?

4 Replies
Clever_Anjos
Employee
Employee

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

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

Hope it helps

Nicole-Smith

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

WHERE exists(IDFromtblCHI, IDFromtblSubList)

richard
Partner
Partner

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.