Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

YTD Fiscal Year

I am trying to get Fiscal Year> YTD to work. When I attempt to apply the same logic I used to get YTD in Calendar Year it keeps returning calendar year YTD values.

What do I need to change this? Below is my code for calculating fiscal year. I have attempted to calculate my own YTD equations with in the code, but was not successful.

'master_date' is a value I share between both databases I am combining.


[Fiscal Calendar]:
LOAD date(date#(20011101,'YYYYMMDD')+recno(),'MM/DD/YY') AS "master_date"
AUTOGENERATE today()-date#(20011101,'YYYYMMDD')
;
LEFT JOIN ([Fiscal Calendar])
LOAD
"master_date",
date(monthstart(master_date),'MMM YY') AS "MonthFisical",
date(yearstart(master_date,1,11),'YYYY') AS "YearFiscal",
Year2Date(master_date) * -1 AS YTD_Flag_Fiscal, //attempt one
Year2Date(master_date,-1, 1, $(vToday))*-1 AS LY_YTD_Flag_Fiscal, //attempt two
YearToDate(master_date, -1, Year(Today(1))) AS Year_YTD_Fiscal //attempt three
RESIDENT [Fiscal Calendar]
;


Thanks for any help on this matter.

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

From the help text:

YearToDate( date [ , yearoffset [ , firstmonth [ , todaydate] ] ] )

So, if your fiscal year starts in April, for instance:

yeartodate(master_date, 0,4) as YTD_Flag_Fiscal,
yeartodate(master_date,-1,4) as LY_YTD_Flag_Fiscal,

That's how I read the help text, anyway.

View solution in original post

2 Replies
johnw
Champion III
Champion III

From the help text:

YearToDate( date [ , yearoffset [ , firstmonth [ , todaydate] ] ] )

So, if your fiscal year starts in April, for instance:

yeartodate(master_date, 0,4) as YTD_Flag_Fiscal,
yeartodate(master_date,-1,4) as LY_YTD_Flag_Fiscal,

That's how I read the help text, anyway.

Not applicable
Author

Just reading to much into it. Sometimes it is easier to just go back to the basics.

Thanks.