# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Rules, plus terms and conditions, can be found here.
Not applicable

My client requirement is to calculate YTD and MTD values as i'm new to qlik please help

Tags (1)
1 Solution

Accepted Solutions
MVP

Check the attached

YTD

=Sum({<OrderDate = {"\$(='>=' & YearStart(Max(OrderDate), 0, 4) & '<=' & Max(OrderDate))"}, MonthYear, Year, Month>}Sales)

MTD

=Sum({<OrderDate = {"\$(='>=' & MonthStart(Max(OrderDate)) & '<=' & Max(OrderDate))"}, MonthYear, Year, Month>}Sales)

2 Replies
MVP

Check the attached

YTD

=Sum({<OrderDate = {"\$(='>=' & YearStart(Max(OrderDate), 0, 4) & '<=' & Max(OrderDate))"}, MonthYear, Year, Month>}Sales)

MTD

=Sum({<OrderDate = {"\$(='>=' & MonthStart(Max(OrderDate)) & '<=' & Max(OrderDate))"}, MonthYear, Year, Month>}Sales)

Contributor

Hi Expressions would be like as below for YTD,QTD,MTD

YTD - Year To Date

A date should be selected and it will look for the Starting date of the year to the selected date.

Ex: date selected is 21-03-2014 then YTD is 01-01-2014 to 21-03-2014

Expression would be

Sum({<Year=, Month=, Quarter=, Week=, DateField=, DateNum={">=\$(=Num(YearStart(Max(DateNum))))<=\$(=Max(DateNum))"}>} Sales)

QTD- Quarter to Date

In the place of year use Quarter

Sum({<Year=, Month=, Quarter=, Week=, DateField=, DateNum={">=\$(=Num(YearStart(Max(DateNum))))<=\$(=Max(DateNum))"}>} Sales)

MTD- Month to Date

Sum({<Year=, Month=, Quarter=, Week=, DateField=, DateNum={">=\$(=Num(MonthStart(Max(DateNum))))<=\$(=Max(DateNum))"}>} Sales)

WTD- Week to Date

Sum({<Year=, Month=, Quarter=, Week=, DateField=, DateNum={">=\$(=Num(WeekStart(Max(DateNum))))<=\$(=Max(DateNum))"}>} Sales)