Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

YTD and MTD

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

1 Solution

Accepted Solutions
its_anandrjs

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

View solution in original post

4 Replies
hic
Former Employee
Former Employee

alexandros17
Partner - Champion III
Partner - Champion III

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.

its_anandrjs

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

Agis-Kalogiannis
Employee
Employee

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