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

Problem with Calendar Script

I keep getting the following error message in my calendar script:don't see where there is a problem:

Error in expression: ')' expected

 

I have narrowed it down to this part of the script that is causing the problem:

 

LET vYTD= Floor(MakeDate(Year(Today()), (Month(Today())-1), Day(MonthEnd(Today()))-1));

If(InYearToDate(Date, $(vYTD), 0)
or InYearToDate(Date, '12/31/2013', -1)
or InYearToDate(Date, '12/31/2013', -2)
or InYearToDate(Date, '12/31/2013', -3)
or InYearToDate(Date, '12/31/2013', -4)
, 1, 0) as _YTD,


If(InYearToDate(Date, $(vYTD), 0)
or InYearToDate(Date, $(vYTD), -1)
or InYearToDate(Date, $(vYTD), -2)
or InYearToDate(Date, $(vYTD), -3)
or InYearToDate(Date, $(vYTD), -4)
, 'YTD') as YTD,

14 Replies
Nicole-Smith

The following will give you the end date of last month:

LET vYTD = Monthend(Addmonths(today(),-1));

Anonymous
Not applicable

The makedate() in this expression is:

makedate(2014,0,30) - that is month is 0 (January minus 1), hence the error.

If you want it to be the end of the previous month, use

=monthend(today(),-1)

Not applicable

Hi,

You add expression in  text box and check it out..

zagzebski
Creator
Creator
Author

My YTD field doesn't populate with this variable:

LET vYTD =monthend(today(),-1)

If(InYearToDate(Date, $(vYTD), 0)
or InYearToDate(Date, $(vYTD), -1)
or InYearToDate(Date, $(vYTD), -2)
or InYearToDate(Date, $(vYTD), -3)
or InYearToDate(Date, $(vYTD), -4)
, 'YTD') as YTD

Anonymous
Not applicable

Change it a little, add floor():

LET vYTD =floor(monthend(today(),-1))

Edit:  Some explanation.
Without floor, the variable returns date in format 12/31/2014.  When you use it this way - $(vYTD), it is calculated as 12 divide by 31 divide by 2014.  Not what you want.  So, you either use floor to keep it numeric, as it was before (the value of this date is 41639), or change all your $(vYTD) in expression to simple vYTD, so it doesn't calculate.  I think it is easier to change in one place.