Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
rubenares
Partner - Contributor
Partner - Contributor

Set Analysis sum max date qty

Working with the following dataset:

CustomerDateQty
A31/3/20190.9
A31/3/20190.2
A30/6/20190.2
A30/6/20190.2
B30/6/20180.6
B30/9/20180.4
B30/9/20180.2

 

We want to get following result:

CustomerLast DateLast Qty
A30/6/20190.4
B30/9/20180.6

 

We have resolved Last Date measure with following code:

Max({<Date =>} Date )

But we have problems to create Last Qty measure, we are trying with following code:

Sum({<Date = {"$(=Max({<Date =>} Date ))"}>} [Qty])

But it calculates max date globally, not by customer.

Aditionally, these measures should ignore date selection.

 

Thanks in advance!

 

2 Replies
tresB
Champion III
Champion III

Try:

 

FirstSortedValue( {<Date>} Aggr({<Date>} Sum({<Date>} Qty), Customer, Date), -Aggr(Date,Date))

sunny_talwar
MVP
MVP

If I may, I think we should ignore selection of Date within Aggr(Date, Date) also. and I am not sure if this is important or not, but I usually use the same Aggr() dimensions as the first part.

FirstSortedValue({<Date>} Aggr(Sum({<Date>} Qty), Customer, Date), -Aggr(Only({<Date>}Date), Customer, Date))