Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
nishanthi_8
Creator
Creator

How to use variable in the where clause ?

I need to restrict the table loading by giving some condition in the where clause. And I need to store the possible values in the variable

For example :

      LET Var='Chairs,tables';

LOAD

----

------

--------

WHERE (Products='$(Var)');

But i encounter some error in this. Is there any possible way to do this. I need to store the possible values in the variable

1 Solution

Accepted Solutions
Anonymous
Not applicable

Why do you need a variable to filter the table?

Can you not use an inline load? i.e

See sample below...If you use this, the filter field Products must not be loaded prior to using this...

The filter text (Tables, Chairs) must be exact match as in your table/Case sensitive.

Filter:
LOAD * INLINE [
Products
Tables

Chairs

];

YourTable:

LOAD *
FROM
YourSource...
where Exists(Products);

View solution in original post

5 Replies
Not applicable

Hi,

you can use this

LOAD

---

---

WHERE  MIXMATCH(Products, $(Var) );



nishanthi_8
Creator
Creator
Author

No nothing is fetched up. The comma and the quotes separation in variable is the thing to be taken care of. I need help in that

Anil_Babu_Samineni

You can change variable like below

SET Var='Chairs,tables';

Please read this !!!

SET vs. LET

I got into a conversation with someone today who was struggling to understand the difference between SET and LET. It wasn't the first time I've had this conversation so thought I'd explain it here too in case any QV newbies were also struggling with it.

SET is taken literally and what is on the right of the equals is written into the variable. So writing:

SET vMyVariable = 5*2;

Would result in vMyVariable containing "5*2".

LET is used when you wish QlikView to equate what is on the right of the equals and write the answer into the variable. So writing:

LET vMyVariable = 5*2;

Would result in vMyVariable containing "10".

Simples!

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable

Why do you need a variable to filter the table?

Can you not use an inline load? i.e

See sample below...If you use this, the filter field Products must not be loaded prior to using this...

The filter text (Tables, Chairs) must be exact match as in your table/Case sensitive.

Filter:
LOAD * INLINE [
Products
Tables

Chairs

];

YourTable:

LOAD *
FROM
YourSource...
where Exists(Products);

tamilarasu
Champion
Champion

Hi Nishanthi,

Try something like below

SET Var= 'Chairs' , 'tables' ;

LOAD

----

------

--------

WHERE WildMatch(Products, $(Var) );