Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Gysbert_Wassenaar

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

View solution in original post

5 Replies
Gysbert_Wassenaar

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
Author

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?

swuehl
MVP
MVP

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);

Gysbert_Wassenaar

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
Author

Thanks Guys!

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

Best,

Brad