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

pls give me expressions for yytd,lyytd?

pls give me expressions for  yytd,lyytd?

1 Solution

Accepted Solutions
evan_kurowski
Specialist
Specialist

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

View solution in original post

4 Replies
evan_kurowski
Specialist
Specialist

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

Not applicable
Author

if we replace instead of yearstart to  monthstart  then it is  myytd right ?  like   qyytd also......

ashfaq_haseeb
Champion III
Champion III

Hi have a look at the below post

YTQ, QTD, MTD and WTD

Regards

ASHFAQ

evan_kurowski
Specialist
Specialist

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