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

Aggr() function

Hi guys,

I have a table as below:

yearidcustidsalesorderamt
2012A115
2012A210
2012A316
2009B112
2010B215
2012B312
2013B414

And I use the aggr function to setup a expression to calculate the min salesorder group by custid,yearid,just like below:

yearidcustidsalesorderamtMin_Salesorder_Year
2012A1151
2012A2101
2012A3161
2009B1121
2010B2152
2012B3123
2013B4144

And I want to have another expression to calculate the Min_Salesorder_Year-1 for Year-1,looks like:

yearidcustidsalesorderamtMin_Salesorder_YearMin_Salesorder_Year-1
2012A1151-
2012A2101-
2012A3161-
2009B1121-
2010B21521
2012B3123-
2013B41443

Anyone has idea of how to write the expression about the "Min_Salesorder_Year-1"?

Thanks a lot.

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try if(yearid-above(total yearid)=1,above(total [Min_Salesorder_Year]))


talk is cheap, supply exceeds demand

View solution in original post

5 Replies
Not applicable
Author

For example,

yearidcustidsalesorderamtMin_Salesorder_YearMin_Salesorder_Year-1
2009B1121-
2010B21521

I need the value of Min_Salesorder_Year-1 in 2010 equivalent to Min_Salesorder_Year in 2009. It means the value 1 in green same as that in red.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try if(yearid-above(total yearid)=1,above(total [Min_Salesorder_Year]))


talk is cheap, supply exceeds demand
preminqlik
Specialist II
Specialist II

exactly

Not applicable
Author

Thank you very much, it works.

Not applicable
Author

Hi G Wassenaar,

First of all, thank you for your answer,actually I  intend to use this expression as a calculated dimension to classify the customers, but when I put it into the calculated dimension ,only the aggr() dimension works.

     What I want is, for example, a customer who bought in both 2012 and 2011(continuous two years) is considered as a existing customer,and a customer who bought in both 2012 and 2010(not continuous two years) is considered as a reactivated customer,a customer who only bought in current year is considered as a new customer.

     And in this case, do you have any good ideas?