Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

calculation of YTD

Normally YTD means it will calculate from January 1st to till date..

i)Is it possible to calculate a YTD from february to till date?

ii) Is it possible to calculate YTD from specific time like May20th of the year to till date?

Thank you

4 Replies
MK_QSL
MVP
MVP

1)

For Current Year

SUM({<Year =, Quarter =, Month = , Date = {">=$(=MonthStart(YearStart(Today()),1))<=$(=Today())"}>}Sales)

or For Year of Selected Date

SUM({<Year =, Quarter =, Month = , Date = {">=$(=MonthStart(YearStart(Max(Date)),1))<=$(=Max(Date))"}>}Sales)

2)

SUM({<Year =, Quarter =, Month = , Date = {">=$(=Max(Date))<=$(=Today())"}>}Sales)

Not applicable
Author

Thank you Manish.

But the start date and month for calculation should be 20th feb 2015(rather than year start and month start) and from that date I want to calculate till date.

Not applicable
Author

Though this can be achievable in chart expressions, it is advisable to flag data as per your requirement in the script and use the flag in set expression. Something like below

If(Date>=YearStart(Today(),0,2)+19 and Date<=Today(),1,0) as YTD_FLG

Regards,

KKR

MK_QSL
MVP
MVP

For Current Year

SUM({<Year =, Quarter =, Month = , Date = {">=$(=Date(MakeDate(Year(Today()),2,20)))<=$(=Date(Today()))"}>}Sales)

or For Year of Selected Date

SUM({<Year =, Quarter =, Month = , Date = {">=$(=Date(MakeDate(Year(Max(Date)),2,20)))<=$(=Date(Today()))"}>}Sales)

2)

SUM({<Year =, Quarter =, Month = , Date = {">=$(=Max(Date))<=$(=Today())"}>}Sales)