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

Help with advanced aggr

Hi,

I looking for a way to get the first/last invoice value of a customer:

For example: Given this table

Customer
OrderDateProduct
Value
A1/1/2011A30
B1/1/2010B30
B1/1/2010C40
C1/1/2011D30
C1/1/2010E40

I want to create a report with

CustomerMax(OrderDate)
Latest Order Value
A1/1/201130
B1/1/201070
C1/1/201130

I have tried:

firstSortedValue(aggr(sum(Sales), OrderDate, Customer), -OrderDate)

Am I doing something wrong?

Thank you in advance

JM Patino

1 Solution

Accepted Solutions
Not applicable
Author

Just add a "distinct" statement in your expression :

firstSortedValue(distinct aggr(sum(Sales), OrderDate, Customer), -OrderDate)

View solution in original post

2 Replies
Not applicable
Author

Just add a "distinct" statement in your expression :

firstSortedValue(distinct aggr(sum(Sales), OrderDate, Customer), -OrderDate)

Not applicable
Author

Wow it worked.  That was a bit counter intuitive.  Anyway thanks.