Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Make your voice heard! Participate in the 2020 Wisdom of Crowds® Survey. BEGIN SURVEY
Highlighted
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?

Tags (1)
8 Replies
Highlighted
sudeepkm
Valued Contributor III

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

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.

Highlighted
Not applicable

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

Hi,

don't know how to select a variable.

Can you explain that ?

RR

Highlighted
Not applicable

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

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

Highlighted
Not applicable

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

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

Highlighted
sunilkumarqv
Valued Contributor II

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

Try like these

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


Highlighted
Not applicable

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

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

Highlighted
Not applicable

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

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'

Highlighted
jsaradhi
Valued Contributor

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

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.