Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

bimanbeginner
New Contributor II

If statement

Hi There.

Im trying to write an if statement that doesnt seem to be working

I have a field Name

I want to create a new field which defines these Names.

in this field I want Closed,Open and All

I have tried below:

if( Name='Closed','Closed',

If(Name<>'Closed','Active')) as FieldName

This works to get my closed and active steps, how do i get all in the same statement?

FYI :I have many names in this field

Thank You

1 Solution

Accepted Solutions
MVP
MVP

Re: If statement

It seems that you need something like generic field.

Untitled.png

If so, try like:

t1:

Load * Inline [

Status

Closed

ABC

BCD

Not Closed

Opennn

];

t2:

Load

       'All' as GenericStatus,

       Status

Resident t1;

t2:

Load

       Status as GenericStatus,

       Status

Resident t1 where Status='Closed';

Load

       'Open' as GenericStatus,

       Status

Resident t1 where Status<>'Closed';

13 Replies

Re: If statement

As I understood from your post,

Any name having 'Closed' word, you want to declare as Closed.

What are the criteria for All and Active?

Re: If statement

May be this?

If(Name = 'Closed', 'Closed', If(Name = 'Open', 'Open', 'All')) as FieldName

ahaahaaha
Honored Contributor

Re: If statement

Hi

Try

if( Name='Closed','Closed','Active') as FieldName

bimanbeginner
New Contributor II

Re: If statement

Everything with closed will be closed everything else is still active.

but the user must be able to distinguish between closed active and both by selecting one in a list box...

bimanbeginner
New Contributor II

Re: If statement

There is no field defining open names... but the logic is that if it is not closed... then it is open.. or active...

bimanbeginner
New Contributor II

Re: If statement

Hi Andrey... what about all though?

Re: If statement

If you don't have field name called Name. Then how you are calculating? May be check one funny solution with ValueList() ?? If not i may not understand the rek

FYI - My expression may give make sense if you have field called Name

bimanbeginner
New Contributor II

Re: If statement

Sorry i think i havent explained correctly.

The field Name does exist, but there is a name called closed which identifies all closed items all other items will be open hence me using <> to closed in my initial expression... There is no name = 'Open'  the logic is that if it is not closed then it is open

Re: If statement

Can be more specific. Better with example.

Regards

Regards,
Prashant Sangle