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

Sales for current and previous year with if statement

Hi Everyone,

I am looking to create an if statement calculation that says: if it is the current year then return sales.

If possible, I want to accomplish this without a set analysis and without having to create a master calendar as these are just quick calculations that need to be made.

I have something like: sum(if(year(Booked_Date)= Max(year(Booked_Date))), Booked Amount))

Can't get this to work for some reason.

I am also trying to do the same for the previous years' sales.

Please let me know if I'm missing something.

Thanks!

2 Replies
Not applicable
Author

Sorry meant to write: sum(if(year(Booked_Date)= Max(year(Booked_Date)), Booked Amount)) which is still not working though

lakshmikandh
Specialist II
Specialist II

Declare this in Load script variable Let mYr = '=Max(year(Booked_Date))';

And try this expression sum(if(match(year(Booked_Date),$(mYr) ), Booked Amount))