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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
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.