Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
SDT
Contributor III
Contributor III

Trailing twelve month total for top 50 products by revenue??

Hello,

I have been lurking here for a while and gaining tons of awesome insights. I'm a bit stuck on this one though. My data model has line item invoices with an invoice date (on the X-Axis of my chart by month), revenue amount (Revenue), and product number (ProductDescFLX). I would like to produce a chart showing one value each month for the Total revenue from the prior twelve months  for the top 50 products ranked by revenue.

I would like the ranking to be the top 50 products based on the 12 month total revenue.

I tried several versions and this is close but does not seem to produce accurate results when double checked manually.

= RangeSum(above(Sum({$<
ProductDescFLX={"=rank(Sum(Revenue))<=50"}
>} Revenue),0,12))

I'm guessing I need an AGGR() in there somewhere. Any help would be greatly appreciated.

Labels (3)
2 Replies
Kushal_Chawda

= if(rank(RangeSum(aggr(above(total Sum(Revenue),0,12),ProductDescFLX,MonthYear))<=50,

RangeSum(aggr(above(total Sum(Revenue),0,12),ProductDescFLX,MonthYear)),0)

 

SDT
Contributor III
Contributor III
Author

Thank you for the fast reply Kush.  I gave it a shot and got a flat line of zero. The only change I made was to put in the exact field name for Year and Month and add a missing parenthesis for the rank function.

if(rank(RangeSum(aggr(above(total Sum(Revenue),0,12),ProductDescFLX,CYMo)))<=50,
RangeSum(aggr(above(total Sum(Revenue),0,12),ProductDescFLX,CYMo)),0)

Any thoughts?