Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
hopkinsc
Partner - Specialist III
Partner - Specialist III

Nested IF in script

Hi all, 

I can't get a nested if to work in the script, i know its something stupid i am doing but can't figure it out.

What i want is

I have a field 'Employee', 'Type' and a 'Date'. I don't want to see any employees with a type of 'A' or 'B' before 01/01/2017. I want to see any other type before this date though and everything after it. 

can anyone help?

 

2 Solutions

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Where not (Match(Type, 'A', 'B') and Date < MakeDate(2017,1,1))

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

View solution in original post

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

I now have it working, i used..

if(not match([Type],'Basic Training') and [Date]<'01/01/2015',[Type],
     if([Date]>='01/01/2015', [Type])) as [New Type]

 

View solution in original post

6 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Where not (Match(Type, 'A', 'B') and Date < MakeDate(2017,1,1))

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Hi Rob,

I am trying to create a field in the table, so something like...

If(Not Match(Type,'A','B') and Date <01/01/2017,Type) as NewType

 

So that gives me any other type and dates before 01/01/2017, but i then don't get anything after that date, I also want ALL types after that date too. 

The other option is to use an expression in the chart but i can't get that working either..

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

I now have it working, i used..

if(not match([Type],'Basic Training') and [Date]<'01/01/2015',[Type],
     if([Date]>='01/01/2015', [Type])) as [New Type]

 

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Note in my original example the "not" was outside a set of parens. That is key.

if(not (match([Type],'Basic Training') and [Date]<'01/01/2015'),[Type]) as [New Type]

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Hi  Rob,

Ahh yes, i see what you mean. That works, the one i posted also seems to do what i want, would there be a difference? should i change it to the one you suggested or is mine good enough?

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Either one seems to work but I find mine easier to read. Perhaps an even clearer way to write it is:

if(match([Type],'Basic Training') and [Date]<'01/01/2015', null() ,[Type]) as [New Type]

-Rob