Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Can't make =Only([YEAR]-1) working in the expression definition

I am trying to display the cumulative sales for the current and previous year

In the label the expression "=Only([YEAR]-1)" seems to works correclty as show in the screenshot

But I can't make the expression "=sum( {$<Year = {$(=Only([YEAR]-1))}>} AMOUNT ) " working, it always evaluate the current year.

Am I doing anything wrong ?

/Eric

1 Solution

Accepted Solutions
Not applicable
Author

Hi

u select the year in ur  year field what ur using in the expression

sum({<YEAR={$(=only(YEAR)-1)}>}[Net Amount])


View solution in original post

9 Replies
jfkinspari
Partner - Specialist
Partner - Specialist

Try and move the "-1" out of the only function like this

"=sum( {$<Year = {$(=Only([YEAR])-1)}>} AMOUNT ) "

Not applicable
Author

Hi

sum({<YEAR={$(=only(YEAR)-1)}>}[Net Amount])

it show values only when u select the year

otherwise it show all 0,s

u must select the one year for it

nirav_bhimani
Partner - Specialist
Partner - Specialist

HI ,

Try this Expression.

Current Year Sales:

sum({<Year= {"$(=Max(Year))"}>} AMOUNT )

Last Year Sales:

Sum({<Year = {"$(=Max(Year )-1)"}, Quarter=, Year=>} AMOUNT )

Regards,

Nirav Bhimani

Not applicable
Author

Hi,

That did not change anything

Not applicable
Author

I ahve a list box property where I select the [YEAR] attribute.

Not applicable
Author

The max year did not solve the problem, could it be that my data is corrupted ?

nirav_bhimani
Partner - Specialist
Partner - Specialist

Hi,

Both expressions will work. Can u share a demo file so that I can help you.

Regards,

Nirav Bhimani

Not applicable
Author

Hi

u select the year in ur  year field what ur using in the expression

sum({<YEAR={$(=only(YEAR)-1)}>}[Net Amount])


Not applicable
Author

Thanks a lot, I add one characters $ that was not needed