Discussion Board for collaboration related to QlikView App Development.
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!
it looks like you are comparing two different types, make both dates in your compare
Hi @dhgaimez
Try with variable for this .
ex:
vpast6Month = Date(AddMonths(max(YearMonth), -6),'YYYY-MM')
if(YearMonth = '$(vpast6Month)',0,1)
Hope it helps
Try
if(YearMonth = text(Date(AddMonths(max(YearMonth), -6),'YYYY-MM')), 0, 1)
-Pradosh
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