Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Vijen_M
Contributor III
Contributor III

Query

How should i get MTD,LMTD,YTD,Last12 month, i have a date column in which date are from year 2019 to year 2022 till 22 nov

Labels (3)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

MTD

sum({<Datefield = {">=$(=Date(Monthstart(Max(Datefield ))))<=$(=Date(Max(Datefield )))"}>} SomeMeasure)

LMTD

sum({<Datefield = {">=$(=Date(Monthstart(Max(Datefield ),-1)))<=$(=Date(AddMonths(Max(Datefield ),-1)))"}>} SomeMeasure)

YTD

sum({<Datefield = {">=$(=Date(YearStart(Max(Datefield ))))<=$(=Date(Max(Datefield )))"}>} SomeMeasure)

Last 12 Months

sum({<Datefield = {">=$(=Date(Monthstart(Max(Datefield ),-12)))<=$(=Date(Max(Datefield )))"}>} SomeMeasure)

replace Datefield with your actual date field name

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

1 Reply
vinieme12
Champion III
Champion III

MTD

sum({<Datefield = {">=$(=Date(Monthstart(Max(Datefield ))))<=$(=Date(Max(Datefield )))"}>} SomeMeasure)

LMTD

sum({<Datefield = {">=$(=Date(Monthstart(Max(Datefield ),-1)))<=$(=Date(AddMonths(Max(Datefield ),-1)))"}>} SomeMeasure)

YTD

sum({<Datefield = {">=$(=Date(YearStart(Max(Datefield ))))<=$(=Date(Max(Datefield )))"}>} SomeMeasure)

Last 12 Months

sum({<Datefield = {">=$(=Date(Monthstart(Max(Datefield ),-12)))<=$(=Date(Max(Datefield )))"}>} SomeMeasure)

replace Datefield with your actual date field name

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.