Qlik Community

Ask a Question

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
March 11, 2PM EST: Do More with Qlik - Getting Started wtih Qlik Sense SaaS - Redux. REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
laura_1
Partner
Partner

PY Calculation when Year filter is selected

Hi, 

Is there a way to calculate PY values when a value is selected in year filter? 

Let's assume we have the following values:

Year, Sales

2019, 50

2018, 40

2017, 20

If I select 2019 in the year filter, sum ({<Year={"$(=max(Year))"}>} sales) returns current year (2019) values, but calculation for PY sum ({<Year={"$(=max(Year))-1"}>} sales) returns zero.

1 Solution

Accepted Solutions
dilipranjith
Partner
Partner

thats odd. 

i checked below in my local app and it works.

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

which version of sense are you on.  newer versions give an output preview of the dollar sign expansion. see below. check that

Capture.PNG

Capture.PNG

View solution in original post

5 Replies
dilipranjith
Partner
Partner

your -1 is not inside the dollar sign expansion

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

change to below

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

laura_1
Partner
Partner

Thanks for your quick reply but it still returns zero..

dilipranjith
Partner
Partner

thats odd. 

i checked below in my local app and it works.

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

which version of sense are you on.  newer versions give an output preview of the dollar sign expansion. see below. check that

Capture.PNG

Capture.PNG

View solution in original post

laura_1
Partner
Partner

Checked again and it worked, thanks very much for your help 🙂 

dilipranjith
Partner
Partner

Great. Mark as answered to close the thread