Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
lain_
Contributor III
Contributor III

SumProduct Between Columns in Pivot Table

I have a pivot table like the one below. The values are calculated with expressions. Is there any way to get the sum product of the N and Y columns as shown in the ? column. The goal is to eventually graph the sum product while knowing its corresponding (N, Y) and (X, Z).

  NY?
XA14 
 B25 
 C36(1*4)+(2*5)+(3*6)
ZA25 
 B36 
 C47(2*5)+(3*6)+(4*7)

 

6 Replies
Saravanan_Desingh

One Solution is.

tab1:
LOAD * INLINE [
    D1, D2, N, Y
    X, A, 1, 4
    X, B, 2, 5
    X, C, 3, 6
    Z, A, 2, 5
    Z, B, 3, 6
    Z, C, 4, 7
];

Left Join(tab1)
LOAD D1, Evaluate(Concat(N&'*'&Y,'+')) As Exp
Resident tab1
Group By D1;
Saravanan_Desingh

Output.

commQV73.PNG

Saravanan_Desingh

FrontEnd solution.

Case1:

Dimension : D1

Expression: Sum(N*Y)

Case2:

Dimension : D1, D2

Expression: Sum(TOTAL <D1> N*Y)

commQV74.PNG

 

lain_
Contributor III
Contributor III
Author

Thank you for the response. The logic makes sense but for some reason it still doesn't work. I thought the simplified example could be easily extended.  I did sum(total <Dim1> Expression1.1*Dim2 ) but it says that Expression1.1 is a bad field name. It would be nice to eventually get the second table to then graph.

 Dim3NY  
Dim1Dim2Expression1.1Expression1.2??
A115  
 226(1*1)+(2*2)(1*5)+(2*6)
B137  
 248(1*3)+(2*4)(1*7)+(2*8)

 

 NY
A(1*1)+(2*2)(1*5)+(2*6)
B(1*3)+(2*4)(1*7)+(2*8)

 

Saravanan_Desingh

Can you paste your code here? Also how your input looks like? Whatever you have pasted here is from Excel I guess.

lain_
Contributor III
Contributor III
Author

Everything in the table is what I have in the QlikView pivot table. The dimensions are essentially, Dim1(A, B), Dim2(1, 2), Dim3(N, Y). Dim1 and Dim3 are strings and Dim2 is numbers. The expression calculates another value using this expression: sum(some_info)/sum(total <Dim1> some_info). This calculates the proportions of some_info grouped by Dim1.