Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Skip the ticket, Chat with Qlik Support instead for instant assistance.
cancel
Showing results for 
Search instead for 
Did you mean: 
dhgaimez
Contributor II
Contributor II

YearMonth if statement

Hey all,

I am trying to use an if statement using YearMonth in relation to a calculated value and cannot get it working.

This is working
if(YearMonth = '2020-02',0,1)

Trying to get something like this to work. 
if(YearMonth = Date(AddMonths(max(YearMonth), -6),'YYYY-MM'), 0, 1)

Date(AddMonths(max(YearMonth), -6),'YYYY-MM') outputs 2020-02

Can't figure out why this wouldn't work. Any help is appreciated!

4 Replies
edwin
Master
Master

it looks like you are comparing two different types, make both dates in your compare

MayilVahanan

Hi @dhgaimez 

Try with variable for this . 

ex:

vpast6Month = Date(AddMonths(max(YearMonth), -6),'YYYY-MM')

if(YearMonth = '$(vpast6Month)',0,1)

Hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
pradosh_thakur
Master II
Master II

Try

if(YearMonth = text(Date(AddMonths(max(YearMonth), -6),'YYYY-MM')), 0, 1)

-Pradosh

Learning never stops.
edwin
Master
Master

as i said both side of the equation should have same data type convert both to date:

if(date(YearMonth&'-01') = AddMonths(date(max(YearMonth)&'-01'), -6), 0, 1)

you dont need the formatting to YYYY-MM