Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
stjernvd
Partner - Creator
Partner - Creator

Aggr Function in Set Analysis

Hi,

To return sale of highest sold product for previous year I found this expression:

=Max({<Year={$(=Max(Year)-1)}>} aggr (sum( {<Year={$(=Max(Year)-1)}>} Sale),Company_Name,Product))


Why does does Max have to have {<Year={$(=Max(Year)-1)}>} after it, and not just Max(aggr(sum and then the rest?

thanks

4 Replies
Not applicable

Hi,

The above expression is used to get max sales last year.

stjernvd
Partner - Creator
Partner - Creator
Author

Hi Amardip,

Thank you.

I am just wondering why the function isn't:

Max(aggr (sum( {<Year={$(=Max(Year)-1)}>} Sale),Company_Name,Product))

instead of

=Max({<Year={$(=Max(Year)-1)}>} aggr (sum( {<Year={$(=Max(Year)-1)}>} Sale),Company_Name,Product))

Do they both mean the same thing? Why is Max(year) used twice?

sunny_talwar

Have you tried using both the expressions? Do they give you the same results, if they do then in your case it won't matter, but there are times (hard to give an example) where it does make sense to use a set expression in the outermost function also. Ultimately it all depends on the requirement.

Best,

Sunny

Kushal_Chawda

As per your statement "sale of highest sold product for previous year" you can do something like attached here