Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
kuan
Contributor
Contributor

How to find products that have been bought consistently for the past 3 years

Hi,

I am trying to extract a list of product that has been bought in the last 3 years and rank them by sales. Assuming my data are these

LOAD * INLINE [ 
Product_Name, Year1_Sales, Year2_Sales, Year3_Sales 
Product1, 0, 200, 56000 
Product2, 100, 900, 252000 
Product3, 40000, 1500, 0
Product4, 3000000, 500, 160000 
Product5, Mexico, 0, 122000 
];  

In this case, Product2 and Product4 should be extracted and ranked.
I know I need to use aggr but don't know what to do next. Can anyone help me?
Thanks very much
1 Reply
rafael_neves
Contributor III
Contributor III

Hello

if the Table is organized in this way

in the chart, in the dimension column you can do

AGGR (

IF (

SUM (Year1_Sales)> 0 AND

SUM (Year2_Sales)> 0 AND

SUM (Year3_Sales)> 0

, Product_Name)

, Product_Name)

 

and Measurement Column you can use

SUM (Year1_Sales + Year2_Sales + Year3_Sales)

graciously

Rafael Yoshida