Qlik Community

Qlik Education Discussions

Discussion Board for collaboration related to Qlik Education.

san_qliklearn
New Contributor II

YTD and MTD

Can anyone explain me How does Year to date(YTD) and Month to Date(MTD) works?

1 Solution

Accepted Solutions

Re: YTD and MTD

Hi,

There are many post related to the YTD and MTD

YTD :- this stands for Year to date means any metric value from Start of year and till date means today date and with help of SET expression we find

=Sum({$<Date = {'>$(=Max((YearStart(Date)))) <=$(=Max(Today()))'}>} Metrics )

MTD:- This stands for Month to date means Start of month which is current month to till date today date.

=Sum({$<Date = {'>=$(=Max((MonthStart(Date)))) <=$(=Max(Datefield))'}>} Metrics)

Regards

Anand

4 Replies
Employee
Employee

Re: YTD and MTD

Re: YTD and MTD

Generlly you start from a date on which you build a master calendar (look in the community, you will find several examples)

The calendar contains even week, month and year fields, I prefer to work with 201409 as month field or 201427 as week field because sorting and selection is easier.

If you need YTD just write in your expression a condition myDateField <= today() even with set analysis or not.

Re: YTD and MTD

Hi,

There are many post related to the YTD and MTD

YTD :- this stands for Year to date means any metric value from Start of year and till date means today date and with help of SET expression we find

=Sum({$<Date = {'>$(=Max((YearStart(Date)))) <=$(=Max(Today()))'}>} Metrics )

MTD:- This stands for Month to date means Start of month which is current month to till date today date.

=Sum({$<Date = {'>=$(=Max((MonthStart(Date)))) <=$(=Max(Datefield))'}>} Metrics)

Regards

Anand

Employee
Employee

Re: YTD and MTD

Hi Sadeep

You can also find the YTD and MTD flag fields as part of your MasterCalendar script.

In this case, we use the inyeartodate() and inmonthtodate() to calculate them.

The inyeartodate function will return true(-1) when your date from the dataset belongs to the period from the beginning of this year (01/01) until today.

Respectively, the inmonthtodate function will return true(-1) when your date from the dataset belongs to the period from the beginning of this month until today.

Regards

Agis

Community Browser