Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Ranjanac
Contributor III
Contributor III

where Exists()

I want the out put : Employee name & salary where (Salary) >20000

my code:

Employee: //* Loading table

LOAD * inline [

Ename,ID,Salary

Bill,001,20000

Ranjana,002,30000

Lakshya,003,35000
];

EmployeeAddresses:

Load

Ename as Name,

Salary

Resident Employee where Exists (Salary) >20000;

 

but this code will show all the existing values.. 

Ranjanac_0-1692348328985.png

 

Did this load script work ? How to get the correct output.? 

1 Solution

Accepted Solutions
marcus_sommer

Try it with:

LOAD * inline [

Ename,ID,Salary

Bill,001,20000

Ranjana,002,30000

Lakshya,003,35000
] where Salary > 20000;

View solution in original post

4 Replies
marcus_sommer

Try it with:

LOAD * inline [

Ename,ID,Salary

Bill,001,20000

Ranjana,002,30000

Lakshya,003,35000
] where Salary > 20000;

Tanish
Partner - Creator
Partner - Creator

HI,

EmployeeAddresses:

Load

Ename as Name,

Salary

Resident Employee where Salary >20000;

 

Don't use Exists function...

and I can see two tables in your  DataModel, if u need it then fine, if not then write Drop Statement.

 

For Example,

Drop table Employee;

Ranjanac
Contributor III
Contributor III
Author

it works with "where Salary > 20000" Thanks.

But, where exactly we're using where Exists ? how can we optimized this query ?

marcus_sommer

Exists() evaluates if this field-value exists within the loaded data and is not directly related against the current load else also all previous loaded field-values. For this it looked within the system-table if the value is there or not and returning a TRUE or FALSE. Any other evaluation like >= <= or whatever isn't possible with this function.

Nevertheless this feature could be often applied for tasks like yours - by preparing appropriate data in beforehand. In your case maybe with something like:

temp: load 20000 + (recno() * 1000) as Salary autogenerate 100;

LOAD * inline [

Ename,ID,Salary

Bill,001,20000

Ranjana,002,30000

Lakshya,003,35000
] where exists(Salary);

Depending on the possible variety of values the data-generation part in beforehand may need some more logic and efforts. By rather small tables and/or other sources as qvd- or resident-loads (without any other processing) the performance impact would be not really significant.