Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
kralj_matej
Contributor II
Contributor II

Sales for previous year - sum if aggr

Hello. I want to show gross sales only for 2011 year by using sum, if and aggr. Can someone tell me why is this function wrong and write down the correct function? Why I need at least two parameters for aggr? I am new user and would very appreciate help.

"Gross sales" is measure, not field.

kralj_matej_1-1656948897589.png

kralj_matej_3-1656948930791.png

Thanks!

Labels (3)
1 Solution

Accepted Solutions
kralj_matej
Contributor II
Contributor II
Author

Thank you for help. Unfortunately, function does not work. It says there is error in expresion. Meanwile, i came up with new function which, luckily, works.

sum({$<[OrderDate.autoCalendar.Year] = {2011} >} [Order details.UnitPrice]*Quantity)

Thank you for your time and effort. 

BR, Matej

View solution in original post

5 Replies
Nicole-Smith

The aggr() function calculates an expression over a specified dimension.  So your first parameter should be the expression you are trying to calculate, and the second (and potentially third, fourth, etc.) parameter should be the dimension(s) you are trying to calculate the expression over.  

In the function you have, you say Gross Sales is your measure, so you need to put in dimension(s) to calculate the expression over.

https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/aggr.htm

sidhiq91
Specialist II
Specialist II

@kralj_matej  Why can't you use a set analysis to get the desired output. As per my Understanding if you need to find the Sum of Gross Sales just for 2011. It could be something like below. Let me know if it has helped you.

Sum({<[OrderDate.autocalendar.Year]={'2011'}>}[Gross Sales])

kralj_matej
Contributor II
Contributor II
Author

Thank you for advice. I found a solution.

kralj_matej
Contributor II
Contributor II
Author

Thank you for help. Unfortunately, function does not work. It says there is error in expresion. Meanwile, i came up with new function which, luckily, works.

sum({$<[OrderDate.autoCalendar.Year] = {2011} >} [Order details.UnitPrice]*Quantity)

Thank you for your time and effort. 

BR, Matej

Anonymous
Not applicable

testing