Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

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
MVP
MVP

How to sum the ordervalue of the last 3 orders?

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

2 Replies
MVP
MVP

How to sum the ordervalue of the last 3 orders?

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

How to sum the ordervalue of the last 3 orders?

Thanks Stefan, sometimes it's just so easy.

Community Browser