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

What condition to be use for month year

Good Day,

Below are my script to get previous month with current year less than of LPD date that will be tagged as Y else N,  I used below script in script editor but I got wrong results.

IF(DATE(LPD,'MMM-YYYY')  < Month(Addmonths(Today(),-1)),'Y','N') AS NON_STARTER

Please help me on this

 

Thanks

 

Labels (2)
2 Solutions

Accepted Solutions
Channa
Specialist III
Specialist III

comparing date is not in same format

DATE(LPD,'MM/DD/YYYY')<monthstart((Addmonths(Today(),-1)))

Channa

View solution in original post

kristeljoymalapitan
Author

Hi  it works,

I got the month and year using below script, however out of calculation memory encountered after loading in app overview.

IF(MonthName(LPD) < MonthName(Addmonths(Today(), -1)), 'Y', 'N') AS NON_STARTER

 

Thanks

View solution in original post

5 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Date(..) is a format function that does not change the underlying value and does not produce a month number, so the comparison will not work correctly. I don't have much information on your data and I am not sure what your intent is, but perhaps you want something like one of these:

IF(LPD < MonthStart(Addmonths(Today(), -1)), 'Y', 'N') AS NON_STARTER
or
IF(Month(LPD) < Month(Addmonths(Today(), -1)), 'Y', 'N') AS NON_STARTER

 

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
kristeljoymalapitan
Author

Hi Jontydkpi,

It works but we need to considered also the year, I need to get month with year

Thanks
jonathandienst
Partner - Champion III
Partner - Champion III

The first expression can handle years. Or modify the second one to use MonthName(...) instead of Month(...)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Channa
Specialist III
Specialist III

comparing date is not in same format

DATE(LPD,'MM/DD/YYYY')<monthstart((Addmonths(Today(),-1)))

Channa
kristeljoymalapitan
Author

Hi  it works,

I got the month and year using below script, however out of calculation memory encountered after loading in app overview.

IF(MonthName(LPD) < MonthName(Addmonths(Today(), -1)), 'Y', 'N') AS NON_STARTER

 

Thanks