Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
b_garside
Partner - Specialist
Partner - Specialist

YTD using set analysis or YTD function?

I was trying to determine a common or proven YTD expression, but was not sure if it conforms to best practices.

My goal is not to do accumulation or RangeSum.  I realize many do this in the script via flags, but I prefer in this case to use Set Analysis. But if flags are really the only way then I'm open to see sample code.

Is there a better/simpler way using the YTD function?

Date=is a standard date mm/dd/yyyy

Sum({$ <Date={"$(='>=' & YearStart(max({$} Date)) & '<=' & max({$} Today() ) )"}>} TotalRevenue)

1 Solution

Accepted Solutions
jvitantonio
Specialist III
Specialist III

Hi,

I would do it like this:

sum([$<Date = {">=$(=YearStart(max(all Date))) <= $(=max(today()))"}>} TotalRevenue)

It's simpler and you avoid confusion when using to many special characters.

J

View solution in original post

3 Replies
bbi_mba_76
Partner - Specialist
Partner - Specialist

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

If you want to use only set analysis then consider using the Qlikview Components library to create your calendars and get a lot of very handy set modifiers for free.

If you have very large amounts of data then an AsOf table created in the script might be a better option to keep performance at an acceptable level. If you haven't found it already have a look at this document for an explanation and example qvws: Calculating rolling n-period totals, averages or other aggregations


talk is cheap, supply exceeds demand
jvitantonio
Specialist III
Specialist III

Hi,

I would do it like this:

sum([$<Date = {">=$(=YearStart(max(all Date))) <= $(=max(today()))"}>} TotalRevenue)

It's simpler and you avoid confusion when using to many special characters.

J