Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Three If statements to form a flag

Hi.

i am hoping to acheive the following.

i have three IF statements in my script,  instead of three seperate flags i would like to have only one flag.

if(Tillsvallskod = 4, '1','0') as #FL2,

if (ArtKod <> 'z' or ArtKod = 'z' and SenRoresleDatum > today () - 365, 1,0) as #FL1,

if(ArtKod <> 'a' ,'1', '0') as #FL3,

i have tried using OR after each IF however it seems to throw a syntax on the brackets.

if(Tillsvallskod = 4 or Tillsvallskod =6 OR

if (ArtKod <> 'z' or ArtKod = 'z' and SenRoresleDatum > today () - 365 OR

if(ArtKod <> 'a' ,1,0))) as #Flag

Any help on the following.

i have also attached the qvw .

Best,

Bradley

1 Solution

Accepted Solutions

Re: Three If statements to form a flag

if((Tillsvallskod = 4  or Tillsvallskod =6)

  and (ArtKod <> 'z'  or (ArtKod = 'z' and SenRoresleDatum > today () - 365))

  and ArtKod <> 'a',1,0

  ) as #FL0,


talk is cheap, supply exceeds demand
5 Replies

Re: Three If statements to form a flag

Is this what you're looking for?

if(Tillsvallskod = 4

  or Tillsvallskod =6

  or ArtKod <> 'z'

  or (ArtKod = 'z' and SenRoresleDatum > today () - 365)

  or ArtKod <> 'a',1,0

  ) as #FL0,


talk is cheap, supply exceeds demand
Not applicable

Re: Three If statements to form a flag

Hi Gysbert!

thanks but that solution is not exactly what i am looking for.

i should of stated more clearly perhaps  here is the logic

if statement 1.  Create a Flag where Tillsvallkod = 4, or 6 , (the rest should be discluded i.e 3)

if statement 2. Artkod z should appear in the list however if Artkod z has not moved in the last year then it should be discluded.

if statement 3. Artkod = 'a' should be discluded totaltly.

these flags in essence should be 111 as i had in my example , however i dont want to confuse the user by flags laying out in the front end tablebox,.

ultimately bringing everything down to one flag will be better  i assume?

MVP
MVP

Re: Three If statements to form a flag

It seems like you are interested in the records where all Flags are set to 1, not any of them.

So you need AND operator here.

Main:

LOAD *,

          if(#FL1 and #FL2 and #FL3,1,0) as #FLAll;

LOAD ArtNr,

//if(isNull(Artkod, 'N', ArtKod) as Artkod

SenRoresleDatum,

Tillsvallskod,

LeveransDatum,

if (isnull(ArtKod), 'N',ArtKod) as ArtKod,

if(Tillsvallskod = 4 or Tillsvallskod =6, '1','0') as #FL2,

if (ArtKod <> 'z' or ArtKod = 'z' and SenRoresleDatum > today () - 365, 1,0) as #FL1,

if(ArtKod <> 'a' ,'1', '0') as #FL3,

Lager

FROM

(ooxml, embedded labels, table is Sheet1);

Re: Three If statements to form a flag

if((Tillsvallskod = 4  or Tillsvallskod =6)

  and (ArtKod <> 'z'  or (ArtKod = 'z' and SenRoresleDatum > today () - 365))

  and ArtKod <> 'a',1,0

  ) as #FL0,


talk is cheap, supply exceeds demand
Not applicable

Re: Three If statements to form a flag

Thanks Guys!

i tried to award fairly with points - both solutions work wonderfully.

Best,

Brad

Community Browser