Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Selgum
Contributor
Contributor

Comparing FromDate-ToDate with same period last year

Hi there,

I have this expresssion for summing sales in a given period. Im trying to build an expression summing sales in the same From/To date period last year, but it doesnt seem to work out.

This year:

Sum( if( Date >= vKampFromDate AND Date <= vKampToDate, Sales))

Last year:

??

 

Thanks in advance

3 Replies
MayilVahanan

Hi @Selgum 

try like this

Sum( if( Date >= AddYears(vKampFromDate,-1) AND Date <= Addyears(vKampToDate,-1), Sales))

Try with set analysis which is faster.

Sum({<Date ={">= $(=Date(AddYears(vKampFromDate,-1),'YourDateFormat')) <= $(=Date(Addyears(vKampToDate,-1),'YourDateFormat'))"}>} Sales))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Selgum
Contributor
Contributor
Author

Thanks for your quick reply. But either or, seem to do the trick

Brett_Bleess
Former Employee
Former Employee

@Selgum  Likely going to need to attach a sample QVW in this case, so folks can see the data model etc. in order to be sure to get you the correct solution on this one.  If you can attach that, use the @symbol to flag Mayil, as that will ensure he gets notification you posted things.  Sorry I do not have anything better to offer.  You can check around the Design Blog area to see if you can find something there:

https://community.qlik.com/t5/Qlik-Design-Blog/bg-p/qlik-design-blog

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.