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: 
Not applicable

Sorting data by years

Good morning people! i'm having a problem with the following script,

its only giving me data from the 0-1 year line and is ignoring the rest.

if(today()-Due_Date>=0 or Today()-Due_Date<=365,'0-1 Years',

if(today()-Due_Date>=366 or Today()-Due_Date<=730,'1-2 Years',

if(today()-Due_Date>=731 or Today()-Due_Date<=1096,'2-3 Years',

if(today()-Due_Date>=1097 or Today()-Due_Date<=1461,'3-4 Years',

if(today()-Due_Date>=1462,'4+ Years'))))) as Years

Any ideas why this is doing this?

Kind Regards.

Paul.

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     You should use and condition instead of or condition here both to be satisfied.

if(today()-Due_Date>=0 and Today()-Due_Date<=365,'0-1 Years',

if(today()-Due_Date>=366 and Today()-Due_Date<=730,'1-2 Years',

if(today()-Due_Date>=731 and Today()-Due_Date<=1096,'2-3 Years',

if(today()-Due_Date>=1097 and Today()-Due_Date<=1461,'3-4 Years',

if(today()-Due_Date>=1462,'4+ Years'))))) as Years

Hope it helps

Celambarasan

View solution in original post

3 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     You should use and condition instead of or condition here both to be satisfied.

if(today()-Due_Date>=0 and Today()-Due_Date<=365,'0-1 Years',

if(today()-Due_Date>=366 and Today()-Due_Date<=730,'1-2 Years',

if(today()-Due_Date>=731 and Today()-Due_Date<=1096,'2-3 Years',

if(today()-Due_Date>=1097 and Today()-Due_Date<=1461,'3-4 Years',

if(today()-Due_Date>=1462,'4+ Years'))))) as Years

Hope it helps

Celambarasan

jagan
Partner - Champion III
Partner - Champion III

Hi,

Use AND instead of OR in the If statement.

Regards,

Jagan.

Not applicable
Author

Thankyou! Much appreciated!