Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
If you are a Qlik Insight Bot user, join this collaborative group: JOIN GROUP
New Contributor III

If Statement with logic in field

Hi All

I am trying to make a Chart If Statement work using a field to inject the logic.

Here are my test data:

Data:

LOAD * INLINE [

Value, Dimension

1, Cars

3, Bikes

];

Logic:

LOAD * INLINE [

Dimension, Logic, Target_Value

Cars, Value < Target_Value, 2

Bikes, Value > Target_Value, 2

];

In my chart, I have used the following test If statement:

if($(=Logic), 1,0)

The challenge I have is that my formula works when one of the dimensions is selected (eg Cars or Bikes):

IfStatement02.PNG

But it does not work in the default state with no selections. It only returns the dash '-' see below:

IfStatement03.PNG

Does anyone have a way to make this scenario work so that the logic works when no selections are made? File attached...

Thanks in advance,

Will

1 Solution

Accepted Solutions
Highlighted

Re: If Statement with logic in field

Hi William,

Have a look at the attached file.

If(Pick(Match(Logic,$(=Concat(Chr(39)& Logic & Chr(39), ','))),$(=Concat(Logic,','))),1,0)

Capture.PNG

View solution in original post

4 Replies
Highlighted
New Contributor III

Re: If Statement with logic in field

Hi,

Create a variable vTest

Capture1.PNG

Use the expression $(vTest)

You will get your output.

Capture.PNG

Thanks,

Uj

Highlighted

Re: If Statement with logic in field

Hi William,

Have a look at the attached file.

If(Pick(Match(Logic,$(=Concat(Chr(39)& Logic & Chr(39), ','))),$(=Concat(Logic,','))),1,0)

Capture.PNG

View solution in original post

Highlighted
New Contributor III

Re: If Statement with logic in field

Many thanks Tamil -  that works brilliantly!

Highlighted
New Contributor III

Re: If Statement with logic in field

Thanks Uj - I like that idea. However, I want to keep the Logic field within the table for now. See Tamil's solution below.