Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Summing two fields in script

Hi, I understand that the sum used together with group by. How'd I apply it in the script though? Let's say to do these:

1. sum both OEM and POS sales as total Sales.

2. Then, I need to calculate total sales for new products released within a certain window.

For example:

Load

     OEM_sale,

     POS_sale,

     Year_Qtr,

     Year_Qtr_Product_Released,

     Sum(if((Year_Qtr - Year_Qtr_Product_Released) <= 30 and (Year_Qtr - Year_Qtr_Product_Released) >= 0, Total Sales)

Can anyone help, please?

Thanks in advance!

10 Replies
Anonymous
Not applicable
Author

Hi thanks. I put the Sum(if(..) statement above the load as preceding load, pls see below. However, something about the scripts that it's not liking and it kinda just freezes on me when i debug it.

Load

    Sum(if((Year_Qtr -Year_Qtr_Product_Released)<=30 and

     (Year_Qtr -Year_Qtr_Product_Released)>=0, Ship_Value + POS_Revenue_Value))    as NP_3YR_Revenue,

     *;

Load

     OEM_sale,

     POS_sale,

     Sum(OEM_sale) + sum(POS_sale)          as Total_Sales,

     applymap('Calendar_Map', Calendar_Id, 0)     as Year_Qtr,

     applymap('Product_Released_Map', Material_Id, 0)     as Year_Qtr_Product_Released,

From

TotalSales.Qvd

(qvd)

Group by Year_Qtr, Year_Qtr_Product_Released;