Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
ltc
Partner - Creator
Partner - Creator

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
Anthony_Ventura
Former Employee
Former 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
Anthony_Ventura
Former Employee
Former 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')))

ogster1974
Partner - Master II
Partner - Master II

Why can't you just do

=Year([date field])

Not sure why you'd need an IF statement for this requirement.
jayanttibhe
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')