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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Xytras
Contributor II
Contributor II

How to sum value if Year(Date) >= Max Year(Date) -1 in Set Analysis

Hi all,

I just started working with Qlik Sense (switching from Spotfire to Qlik).

I'm trying to sum my bar chart data only when the year value from field "MyDate" is >= then Max(Year(Mydate)) - 1 (minus 1).

I tried something like:

Sum( {$<[MyDate.autoCalendar.Year] >= (Max(TOTAL [MyDate.autoCalendar.Year]) - 1)>} ValueInGroupCurrencyUSDFormatted )

but due to my poor knowledge, I've not idea on how to fix it.

Could you kindly help on that?

Regards,

Xy

Labels (2)
3 Replies
ajaykakkar93
Specialist III
Specialist III

Hi,
Instead of this [ Max(Year(Mydate))-1  ] you can use addyears( Year(Max(Mydate))  , -1)

Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting

Xytras
Contributor II
Contributor II
Author

Hi Ajay,

Thanks for your reply.

I modified my expression in set analysis as follow:

sum({<[Date.autocalendar.Year]={"$(=addyears(max(Year(Date))), -1)"}>}ValueInGroupCurrencyUSDFormatted)

but it is doing the sum considering ALL the records, it seems it is not considering  this part {"$(=addyears(max(Year(Date))), -1)"}.

Any thoughts?

Regards.

ajaykakkar93
Specialist III
Specialist III

Hi,

Can you create a variable with the below expression
=addyears( Year(Max(Mydate))  , -1)

then add the variable in your final expression
sum({<[Date.autocalendar.Year]={$(VARIABLE_NAME)}>}ValueInGroupCurrencyUSDFormatted)


Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting