Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
kavitha_kommise
Partner - Contributor III
Partner - Contributor III

calculation of previous year and current year

hello,

I want to calculate previous and current year comparison.

i have tried set expression like below

without variables

=sum({< Year = {"$(=max(Year)-1)"}>} value)

=sum({< Year = {"$(=max(Year))"}>} value)

with variables

v_previousyear=max(year)-1

v_maxyear= max(year)

sum({< Year = {"$(=$(v_previousyear))"}>} value)

sum({< Year = {"$(=$(v_maxyear))"}>} value)

but all the expressions are giving same results.like its is giving current year results for all the expressions.

where did i do mistake.please help me out to solve this.

thanks in advance

kavitha

3 Replies
rubenmarin

Hi Kavitha, maybe it's just a typo but your variables has Year all in lowercase: "year". Field name are case sensitives, it should be "Year".


also there is the option that you are doing selections in another field related with year, like a [Year_Month] field, or a [Date] field, in that case you need to include in set analysis all fields that are filtering data in one year.

To ignore selections in one field you only need to inlcude the name of the field in set analysis:

sum({< Year = {"$(=$(v_previousyear))"}, Month_Year>} value)

Additional contions can/should be added to use the month or date selected by user.

shiveshsingh
Master
Master

Is this resolved?

kavitha_kommise
Partner - Contributor III
Partner - Contributor III
Author

yes shivesh

I corrected myself it is working fine.

Thanks and regards

Kavitha