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

YTD last month

I've used this post to get Rolling 1 and 12 months calculation correct.

http://community.qlik.com/message/243408

Now I want to use the same technique to calculate last month YTD

Since I will load the data after turn of the month.

Below is the string I need to modify so that "-13" becomes more of a variable is there a way to use count?

Sum({<MonthYear ={">=$(=Date(addmonths(Max(MonthYear), -13), 'MMM-YY')) <=$(=Date(addmonths(Max(MonthYear), -1),  'MMM-YY'))"} >} STBEL)

1 Solution

Accepted Solutions
bbi_mba_76
Partner - Specialist
Partner - Specialist

this is not verified, I don't have a qvw...

Sum({<MonthYear ={">=$(=date(makeDate(year(Max(MonthYear))), 'MMM-YY')) <=$(=Date(addmonths(Max(MonthYear), -1),  'MMM-YY'))"} >} STBEL)

View solution in original post

8 Replies
bbi_mba_76
Partner - Specialist
Partner - Specialist

Hi,

if I understand well you don't need the rolling months, you need as min date Jan, 1st and then the year

something like makedate(year(Max(MonthYear)))

Not applicable
Author

But I don't want the current month to be calculated in the YTD

bbi_mba_76
Partner - Specialist
Partner - Specialist

the second part of your expression is ok, no?

I think you have only to modify the start date (first part) to set Jan the 1st

Not applicable
Author

Hi Johan,

Have you tried the YearToDate() function? It returns a boolean value if the date matches with the date interval specified into the parameters. You can do a sum until date value is false. Use help to check the syntax details and parameters.

Regards.

Not applicable
Author

The second part is working fine.

Since I'm new to QV I'm having a hard time to get it to work. I'm not sure exactly how the make date function works and google isn't very helpful either 😃

Not applicable
Author

Hi Jesus,

The thing is that I'm trying to do as much as possible within the expressions

I'll not set any specific parameters like month or year. If I choose to do so my expressions for last year ect stops working 😃

bbi_mba_76
Partner - Specialist
Partner - Specialist

this is not verified, I don't have a qvw...

Sum({<MonthYear ={">=$(=date(makeDate(year(Max(MonthYear))), 'MMM-YY')) <=$(=Date(addmonths(Max(MonthYear), -1),  'MMM-YY'))"} >} STBEL)

Not applicable
Author

Thanks Michele, it works perfect....