Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Hareeshkommineni
Contributor III
Contributor III

YTD QTD WTD MTD

I want to creat YTD QTD MTD WTD Flag's in script level 

and i want create rolling 6 months date's also in script level

can any one help me

thanks & regards

hareesh

5 Replies
Vegar
MVP
MVP

I would recommend you to check out the in... section of the date and time section.

Screenshot_20190326-201426.jpg

 

https://help.qlik.com/sv-SE/qlikview/November2018/Subsystems/Client/Content/QV_QlikView/Scripting/Da...

Hareeshkommineni
Contributor III
Contributor III
Author

Any another sample script show me if possible

 

Vegar
MVP
MVP

image.png

I generated the objects above with the output of the script below.

Calendar: 
LOAD 
	%date,
	DayName(%date) as Date,
	Week(%date) as Week,
	WeekName(%date) as YearWeek,
	Month(%date) as Month,
	MonthName(%date) as YearMonth,
	QuarterName(%date) as YearQuarter,
	Year(%date) as Year,
	InYearToDate(%date,today(),0) as _inYTD,
	InMonthToDate(%date,today(),0) as _inMTD,
	InQuarterToDate(%date,today(),0) as _inQTD,
	InWeekToDate(%date,today(),0) as _inWTD
;
LOAD (Today() - IterNo()+1) as %date
autogenerate 1
WHILE  IterNo()  <= 365 //365 day calendar
;
Hareeshkommineni
Contributor III
Contributor III
Author

InYearToDate(%date,today(),0) as _inYTD,
InMonthToDate(%date,today(),0) as _inMTD,
InQuarterToDate(%date,today(),0) as _inQTD,
InWeekToDate(%date,today(),0) as _inWTD
iam using like this
InYearToDate([Order Date],max([Order Date]),0) as YTD,
InMonthToDate([Order Date],max([Order Date]),0) as MTD,
InQuarterToDate([Order Date],max([Order Date]),0) as QTD,
InWeekToDate([Order Date],max([Order Date]),0) as WTD,
but it shows Invalid expression
can u please give me the another answer
Vegar
MVP
MVP

No you can't use max() as it is an aggregate function. What you can do is
to calculate max([order Date]) in prior to running your calendar script
storing the max into a static variable e.g. vMaxOrderDate and use it
instead of max([order Date]) .

InMonthToDate([Order Date],$(vMaxOrderDate),0) as MTD,