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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

need help

Hello experts,

I need current year sales and previous year sales with out making selections in year field.

A table which consists of ename, sales, and year field(2001-2015)

Then I want to make a report with ename(dim)

//

M1:

LOAD

     ename,

     sales,

     year

FROM

C:\Users\admin\Desktop\QV\qv_recent.xlsx

(ooxml, embedded labels, table is Sheet1);


M2:

LOAD Max(year) as curyear

Resident M1;

LET Vcurdate= Peek('curyear');

Yes, it works fine for current year sales

Sum({$<year={$(Vcurdate)}>}sales)

But if I take previous sales its not working

Sum({$<year={$(Vcurdate)-1}>}sales)

//

I don't know where am wrong.

Any suggestions will be appreciated.

1 Reply
buzzy996
Master II
Master II

try from front-exp using the below syntax.

CY

=num(sum({$<Year = {$(=only(Year))}, Month = {"<=$(=max(Month))"}>} SalesAmount), '$#,##0;($#,##0)')

PY

=num(sum({$<Year = {$(=only(Year) - 1)}, Month = {"<=$(=max(Month))"}>}SalesAmount), '$#,##0;($#,##0)')