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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
nancymarmat
Contributor II
Contributor II

Aggr in set expression using Year and Prior Year not working

I have a Pivot table that displays the value (quantity * cost)  of inventory based on grades 1-5.  I would like to compare two years.  I have the following in two different expressions:

     sum(aggr(sum({$< Year={$(=Only(Year))}>}PieceLength*TRC),GradeDesc, LinkItem, MO, Lot))   this works

and

     sum(aggr(sum({$< Year={$(=Only(Year)-1)}>}PieceLength*TRC),GradeDesc, LinkItem, MO, Lot))   this shows all 0s

The first expression returns data for the year in the selection.  The second expression returns 0 for each grade.

What is the proper syntax to return values for year -1?

Thank you for your help.

1 Solution

Accepted Solutions
sunny_talwar

Try this:

Sum({$< Year={$(=Only(Year)-1)}>}Aggr(Sum({$< Year={$(=Only(Year)-1)}>}PieceLength*TRC),GradeDesc, LinkItem, MO, Lot))

View solution in original post

2 Replies
sunny_talwar

Try this:

Sum({$< Year={$(=Only(Year)-1)}>}Aggr(Sum({$< Year={$(=Only(Year)-1)}>}PieceLength*TRC),GradeDesc, LinkItem, MO, Lot))

nancymarmat
Contributor II
Contributor II
Author

Perfect!  It works!

Thank you so much!