Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
pls give me expressions for yytd,lyytd?
Relative to sliding point in time Selection (moving point):
ytd
Sum({<DateNum={">=$(=Num(YearStart(Max(DateNum)))) <= $(=Max(DateNum))"}>} FIELD)
lyytd
Sum({<DateNum={">=$(=Num(YearStart(AddYears(Max(DateNum),-1)))) <= $(=Num(AddYears(Max(DateNum),-1)))"}>} FIELD)
Always pointing to present day/current year combo (fixed point) :
ytd
Sum({<Year={$(=Year(Today()))}>} FIELD)
lyytd
Sum({<DateNum={">= $(=Num(YearStart(AddYears(Today(),-1)))) >= $(=Num(AddYears(Today(),-1)))"}>} FIELD)
both sets are granularity: by date
Relative to sliding point in time Selection (moving point):
ytd
Sum({<DateNum={">=$(=Num(YearStart(Max(DateNum)))) <= $(=Max(DateNum))"}>} FIELD)
lyytd
Sum({<DateNum={">=$(=Num(YearStart(AddYears(Max(DateNum),-1)))) <= $(=Num(AddYears(Max(DateNum),-1)))"}>} FIELD)
Always pointing to present day/current year combo (fixed point) :
ytd
Sum({<Year={$(=Year(Today()))}>} FIELD)
lyytd
Sum({<DateNum={">= $(=Num(YearStart(AddYears(Today(),-1)))) >= $(=Num(AddYears(Today(),-1)))"}>} FIELD)
both sets are granularity: by date
if we replace instead of yearstart to monthstart then it is myytd right ? like qyytd also......
Yes, swapping MonthStart with YearStart functions will give you Current MTD vs. 1 Yr Ago MTD (to the maximum selected day) comparisons.
Meaning if you select 8/6/2014 on the calendar, the year ago MTD will calculate 6-days from August 2013 (8/1/2013 - 8/6/2013).
For Quarter comparison, there's one extra function
prior year quarter start:
Num(QuarterStart(AddYears(Max(Date),-1)))
If you want to perpetually avoid having long chains of ignore syntax in your set-analysis (i.e. {<Year=,Month=,Quarter=,DateField=, etc.. until you have ignored all possible calendar fields end user might potentially make selections), then it is time to switch your calendar selections/expressions to a system that is driven by alternate states.
EndRangeState:
Selections in this state establish end point for calculation
StartRangeState:
Selections in this state establish the start point for calculations (if necessary)
Default State:
Receive the chronological selections from the "parameter collection" states and calculate against non-chronologically reduced dataset without risk of selection conflicts