To your MasterCalendar, I would try with functions InQuarterToDate and InMonthToDate as flags to know your rolling dates. Take into account that the result of all these year to date functions is "true" or "false". QlikView speaking, true equals to "-1" and false equals to "0", so you should not add to your CurYTD and LastYTD Flags, instead of setting them in the set analysis
Now I understand why my values where on negative, thanks! Another question- any idea how I can make Rolling Months option? I would like to ahow on bar chart Moving Annual Total (ex. for February 2010 there will be shown sum of last 12 months sales etc).
Yes, it sound like that what I need. Right now I am achieving MAT by usage of simple accumulaqtion (12 steps back), but it has disadvantage of showing all of the months in your system (also those that cannot accumalute 12 steps back) and with this I cannot count % MAT (unless you maybe know how to check the difference between bars, current and from previous month?). Below you can see my MAT (at least smth like MAT)
When I tried to use your expression in bart chart, it says 'no data to display'. I faced this problem with some other functions earlier, that's why I though the most convinient would be to use RollingMonths in script.
Having Month and Year as dimensions and sum of values as expression, your should modify the above set analysis changing "CalendarDate" for your master fact date (i.e.: InvoiceDate). You should get results provided you have your master calendar working properly and invoices which dates go from today minus12 months to today.