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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How do i calculate the variable in expression

Dear All,

            How do i calculate the variable in previous year.

Eg:

Vbsc = sum(if(billunit=3,Qty))* sum(if(billunit=5,Rate))

if i use the variable in following condition, its not working.

Current year = sum({$<year={$(=max(year))}>}Vbsc) - its working

Previous = sum({$<year={$(=max(year))}>}Vbsc) - not working

Can any one help me.

Regards,

Antony.

5 Replies
jvitantonio
Specialist III
Specialist III

Hi,

I don't see any differences between current and previous year. Anyway, try this:

Previous = sum({$<year={$(=max(year))-1}>}Vbsc) - not working

Not applicable
Author

Hi,

  Problem not in my condition, problem in variable.

variable is not giving the correct output for previous year, its showing my current year output in previous year.

jvitantonio
Specialist III
Specialist III

The problem is your expression because you are summing the same year. Add a -1 to the variable.

Not applicable
Author

Hi ,

Thanks for your reply...

Can u tel me how ?? i did not understand...

MayilVahanan

Hi,

     Suppose you have year such as  2008,2009,2010,2011,2012

     =Max(Year) gives 2012

     =max(Year)-1 gives 2011

     So,

     = sum({$<year={$(=max(year)-1)}>}Vbsc) give result for previous year

Hope it helps

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