Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikviewforum
Creator II
Creator II

Help required in the writing the below expression

Let's assume Snapshot Date is "25/05/2019" so the below expression gives the sales of Mar,2019 to May,2019

Sum({<Date={'>=$(=MonthStart(Max([Snapshot Date]),-2))<=$(=Date(MonthEnd(Max([Snapshot Date]))))'}>}Sales)

What should be the change in the expression if I want to get the sales same as above months but for next year and previous year (i,e Mar,2020 to May,2020 and Mar,2018 to May,2018)

Please help...

1 Solution

Accepted Solutions
sasiparupudi1
Master III
Master III

Use AddYears

to get last year

Sum({<Date={'>=$(=AddYears(MonthStart(Max([Snapshot Date]),-2),-1))<=$(=Date(AddYears(MonthEnd(Max([Snapshot Date])),-1)))'}>}Sales)

Next Year

Sum({<Date={'>=$(=AddYears(MonthStart(Max([Snapshot Date]),-2),1))<=$(=Date(AddYears(MonthEnd(Max([Snapshot Date])),1)))'}>}Sales)

 

View solution in original post

2 Replies
sasiparupudi1
Master III
Master III

Use AddYears

to get last year

Sum({<Date={'>=$(=AddYears(MonthStart(Max([Snapshot Date]),-2),-1))<=$(=Date(AddYears(MonthEnd(Max([Snapshot Date])),-1)))'}>}Sales)

Next Year

Sum({<Date={'>=$(=AddYears(MonthStart(Max([Snapshot Date]),-2),1))<=$(=Date(AddYears(MonthEnd(Max([Snapshot Date])),1)))'}>}Sales)

 

qlikviewforum
Creator II
Creator II
Author

Thanks! Yes did that somehow forgot there is a function called AddYears.