Do these expression really need alll the Aggr()'s? I cant make head or tail of what these expessions are trying to do. I think you need to revist them and see if they can be simplified first, before you try and add further complexity to them.
Aggr() can be a performance killer, and should only be used when truely necessary.
Yeah!! No. of records for each customer is more than one. That the reason I used Aggr() function, to give more clarity on my expression.
aggr( if(aggr(rank(Avg(NETAMT)), $(vCustomer))= 5, Avg(NETAMT)), $(vCustomer)).
I tried my best to make it clear above, I hope you understood now. This expression trying to get the 5th record value i.e.Avg(NETAMT) from the table. I am using rank function and matching it with my interested value i.e. 5 as the expression using if condition.
The expression works perfectly when I use CUSTOMER instead of vCustomer.