Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Variable with 'and' condition only works partially - what's wrong?

Hello,

I have two fields, Environment and Status. Each Environment can be in any Status.

Env-Status.JPG.jpg

I created the following variable: = If(match(Environment,'Production') and match(Status ,'active'), 'true' , 'false')

to be able to select those combinations, where it is Production-active.

While this part of the variable works fine (the 'true' option), the opposite selection doesn't work (the 'false' part). When I select 'false' , QV shows still everything (= Total number not changing).
Any idea what is going wrong?

8 Replies
sudeepkm
Specialist III
Specialist III

Can you please post your sample QVW?

In your script you can also use like below.

If (Environment='Production' and Status = 'active',1,0) as ProdStsFlag

Then in the UI you can use this flag field.

Not applicable
Author

Hi,

don't know how to select a variable.

Can you explain that ?

RR

Not applicable
Author

yes, I am selecting =$(vProdActive) in a listbox object

Not applicable
Author

sorry, can't share my QVW for two reasons a) size b) confidential company data

but the code you suggested shows same result and behaviour as the one I posted

sunilkumarqv
Specialist II
Specialist II

Try like these

= If(match(Environment,'Production') , True(),flase()) and  if(match (Staus,'active') ,True(),flase())


Not applicable
Author

Ok,

I understand.

This way using a "logical" variable won't work as you expect it. It is working correct (as designed) from the view of Qlikview. Play a little bit with my exam app. You will get always all Environment-Value selected in case of false().

I suggest to create a flag as Sudeep posted above.

RR

Not applicable
Author

I guess I sort of found the solution . In the load script I concatenate the two fields to a new one.

e.g. Environment&Status_Name as CI_Env_Stat .

Now I can filter CI_Env_Stat for 'Productionactive' and create a variable that also checks for anything that is not 'Productionactive'

Anonymous
Not applicable
Author

if your variable (vProdActive ) is defined as
= If(match(Environment,'Production') and match(Status ,'active'), 'true' , 'false')

then, you should be selecting vProdActive and not $(vProdActive).

vProdActive returns the strings (true or false) depending on the selection you make.

$(vProdActive) is evaluating what vProdActive is returning which in this case is a string.