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: 
Amit_B
Creator II
Creator II

Sum Aggr cross multiple

Hi,

A client needs to calculate a certain forecast of sales. The forecasting is done with the help of a table of factors that is divided by month and product type. For example:

  Jan-Feb Mar-Apr ...
Type A 1.2 0.75  
Type B 1.8 0.92  
...      


According to the formula, it is required to multiply the sales of each type of product by the factor of the relevant month. For example:
Actual sales of Type A in Jan&Feb is 100 and in Mar&Apr is 200.. Actual sales of Type B in Jan&Feb is 500 and in Mar&Apr is 150..
So, Predict = (100*1.2)+(200*0.75)+...+ (500*0.75)+(150*0.92)+...

I tried to do with aggregations and with conditions on the months and doesn't work.
How Can I do it easily?

Thanks!

Labels (4)
1 Solution

Accepted Solutions
Ahidhar
Creator III
Creator III

try something like this

tab1:
CrossTable(Period,Factor)
load * Inline
[
Category,Jan-Feb,Mar-Apr
Type A,1.2,0.75
Type B,1.8,0.92
];

left join(tab1)
tab:
load * Inline
[
Category,Period,Sales
Type A,Jan-Feb,100
Type A,Mar-Apr,200
Type B,Jan-Feb,500
Type B,Mar-Apr,150
];

then use pivot table Sales *Factor

Ahidhar_0-1704864429689.png

 

 

View solution in original post

2 Replies
Anil_Babu_Samineni

@Amit_B Perhaps this, With this you will be getting forecast based on each product.

linest_b(total aggr(if(sum(Value),sum(Value)),product),product))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Ahidhar
Creator III
Creator III

try something like this

tab1:
CrossTable(Period,Factor)
load * Inline
[
Category,Jan-Feb,Mar-Apr
Type A,1.2,0.75
Type B,1.8,0.92
];

left join(tab1)
tab:
load * Inline
[
Category,Period,Sales
Type A,Jan-Feb,100
Type A,Mar-Apr,200
Type B,Jan-Feb,500
Type B,Mar-Apr,150
];

then use pivot table Sales *Factor

Ahidhar_0-1704864429689.png