Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Help set analysis

Hello everybody,

I'm trying to build a function that I pull out, per customer, the last date on which he purchased, and on that date, the item purchased with the highest economic value. That is the record with the highest value of the last sale per customer.

I wrote something like this, but it doesn't work.

sum({<DATA_DDT={$( aggr(max(DATA_DDT),C_CLIENTE))}>} aggr(max({<DDT_SN={'S'}>}VAL_DDT),C_CLIENTE,C_ARTICOLO))

DATA_DDT is the date

C_CLIENTE is the customer code

C_ARTICOLO is the article code

VAL_DDT is the article value €

DDT_SN is only a flag to reduce data, it's not important

Can you help me?

5 Replies
Not applicable
Author

You could probably try something like this sample.

nagaiank
Specialist III
Specialist III

Untitled.png

The above result is produced by the attached application. Is this what is needed? (The data used in this application is the same as that used by beanz above

Message was edited by: Nagaian Krishnamoorthy

chematos
Specialist II
Specialist II

I think that could be better to do it in the load script.

Try this:

MaxSales:

Load

     Customer,

     max(Date) as MaxDate,

     FirstSortedValue(distinct SalesAmount, -Date) as  MaxSalesAmountDate

from TABLEX

group by  Customer;

hope this helps

Anonymous
Not applicable
Author

Thanks to everybody but nothing you suggest me works...

chematos
Specialist II
Specialist II

MaxSales:

Load

     C_CLIENTE ,

     C_ARTICOLO ,

     max(DATA_DDT) as MaxDate,

     FirstSortedValue(distinct VAL_DDT, -DATA_DDT) as  MaxSalesAmountDate

from TABLEX

group by  C_CLIENTE , C_ARTICOLO ;