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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
aatish12345
Creator II
Creator II

Date range for years

Hello Everyone,

I have a date field which consists of dates from 2020-01-01 to 2021-08-31

I want to create a new field which will show below values when used in filter

>2021-08-31

2021

2020

<2020-01-01

 

I tried it using if statement but not able to achieve the above expected results..

 

Any help would be really appreciated!

 

Aatish

3 Replies
Vegar
MVP
MVP

Try an IF statement like this

If(DateField>=makedate(2021,9),'>2021-08-31', If(Year(DateField)=2021,'2021', if(Year(DateField)=2020,'2020','<2020-01-01')))

aatish12345
Creator II
Creator II
Author

Hi Vegar,

Thanks for the reply!

Actually I want to make a code dynamic.

The solution you've provided includes hardcoding.

 

Aatish

Vegar
MVP
MVP

Then you would need to replace the har coded  parts with some kind of logic. 

Alternatively you could look into creating an interval table and then apply your groups using interval match