Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to sum the ordervalue of the last 3 orders?

Hi,

how can I sum up the last 3 Orders of a customer?

I tried it with rank-function, but a sum() on rank() doesn't work.

sum(if(rank(Orderdate)<=3,sum(Ordervalue),0))

Please see my application in attachment.

Do you have a solution?

best regards

Peggy

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Well, if you want to keep close to your idea, try this

=sum(aggr(if(rank(Orderdate)<=3,sum(Ordervalue),0),Customer,Orderdate))

you need advanced aggregation to embed an aggregation function like sum into another sum.

Hope this helps,

Stefan

View solution in original post

2 Replies
swuehl
MVP
MVP

Well, if you want to keep close to your idea, try this

=sum(aggr(if(rank(Orderdate)<=3,sum(Ordervalue),0),Customer,Orderdate))

you need advanced aggregation to embed an aggregation function like sum into another sum.

Hope this helps,

Stefan

Not applicable
Author

Thanks Stefan, sometimes it's just so easy.