Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 
					
				
		
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?
 
					
				
		
You could probably try something like this sample.
 
					
				
		
 nagaiank
		
			nagaiank
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		
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
		
			chematos
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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
 
					
				
		
Thanks to everybody but nothing you suggest me works...
 chematos
		
			chematos
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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 ;
