Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Uploads getting stuck in the virus scanner. We are investigating.
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Partner
Partner

Simple If Contains Statement

Hello,

I have a simple statement that I need help with.

If [date] field contains '2016', then display as '2016'

If [date] field contains '2017', then display as '2017'

If [date] field contains '2018', then display as '2018'

How do I properly write this up as one expression?

Thanks!

1 Solution

Accepted Solutions
Highlighted
Employee
Employee

You can enter the following as a chart expression:

=if(OrderDate like '*2016*','2016',

     if(OrderDate like '*2017*','2017',

          if(OrderDate like '*2018*','2018','Other')))

View solution in original post

3 Replies
Highlighted
Employee
Employee

You can enter the following as a chart expression:

=if(OrderDate like '*2016*','2016',

     if(OrderDate like '*2017*','2017',

          if(OrderDate like '*2018*','2018','Other')))

View solution in original post

Highlighted
Master II
Master II

Why can't you just do

=Year([date field])

Not sure why you'd need an IF statement for this requirement.
Highlighted
Creator III
Creator III

Hi 

We can remove the nested If statements altogether ... 

Try below :: 

Pick(wildmatch(OrderDate,'*2016*','*2017*','*2018*',OrderDate),2016,2017,2018,'Other')