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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
rtr13
Contributor III
Contributor III

Dynamic Prior YTD

Hi All,

I have seen numerous questions in regards to YTD calculations, but none in regards to a dynamic YTD calculation.

I am currently using the following set analysis to pull the sum of prior YTD Charges:

=SUM({$<ContactDTS = {'>=$(=AddMonths( YearStart (Today()),-12))<=$(=AddMonths( (Today()),-12))'}>}Charges)

But, when selecting a different year, my value drops to zero. In addition, for some reason, my number isn't accurately reflecting the sum of Charges within the field. 

Has anyone ever created a Prior YTD expression that allows is dynamic to the year selected?

Thanks,

Rose

Labels (2)
1 Solution

Accepted Solutions
treysmithdev
Partner Ambassador
Partner Ambassador

You can use the following to do what you are saying. I would create an additional field of your date field but store it as a number. This will make formatting matching a lot easier.

 

Keep in mind you will have to add/replace/remove other calendar date fields in here. 

Sum({<Year=, MonthYear=, Month=, Week=, Date=, DateNum={">=$(=Num(YearStart(Max(DateNum))))<=$(=Num(MonthEnd(Max(DateNum))))"}>}Charges)

 

Blog: WhereClause   Twitter: @treysmithdev

View solution in original post

1 Reply
treysmithdev
Partner Ambassador
Partner Ambassador

You can use the following to do what you are saying. I would create an additional field of your date field but store it as a number. This will make formatting matching a lot easier.

 

Keep in mind you will have to add/replace/remove other calendar date fields in here. 

Sum({<Year=, MonthYear=, Month=, Week=, Date=, DateNum={">=$(=Num(YearStart(Max(DateNum))))<=$(=Num(MonthEnd(Max(DateNum))))"}>}Charges)

 

Blog: WhereClause   Twitter: @treysmithdev