Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Conditional calculated column in pivot table

Hi everyone,

This is my first time using Qlikview and I kind of got stuck somewhere that should be relatively trivial.

I created a pivot table based on customer numbers as a dimension. Now I'm trying to create a another custom column in this table which is the sum of the sum of the amount (Amount) based on the value of another variable (X). The original table looks like this.


Customer No.
XAmount
11111110
11111150
11111160
1111124444
111116222
111116333
111116-100
11111644
111112112
111112113
111112125

The output table that I want should look like this:

Customer No.Total Amount (X=1)Total Amount (X=6)
11111120455
111112500

What I did is:

- I created a pivot table, with customer No. as Dimension

- I created two expressions, one for each extra column. The expressions are as follows:

Sum( if(X = '1', Amount))

Sum( if(X = '6', Amount))



but I'm not getting correct results. Can someone tell me what am i doing wrong here?

11 Replies
neelamsaroha157
Specialist II
Specialist II

Try Sum({<X = {'1'}>}Amount)

      Sum({<X = {'6'}>}Amount)

sunny_talwar

How are you getting 455 for when X = 6 and Cust No. = 11111? I see 4 rows of data (222+333-100+44 = 499). If this is what you want, then try this

Dimension

Customer No.

Expressions

Sum({<X = {1}>}Amount)

Sum({<X = {6}>}Amount)

Not applicable
Author

You are right, in this case it should be 499. Sorry.

I tried your idea, I still do not get correct results. I'm afraid it has something to do with variable type? can this be the issue?

As I load the variables, I do some things with the Amount variable. Something like this:

LOAD

..

..

..

IF(Y = 'H',replace(Num#(Amount*-1,'0.0'),',','.'),Num#(Amount,'0.0')) AS Amount

..

..

..

effinty2112
Master
Master

Hi Abdullah,

You could make a pivot table with 2 dimensions Customer No.  and X.

Expression: sum(Amount)

good luck

Andrew

sunny_talwar

Can you post a screenshot for your Amount field? Because not sure what the issue is, because it worked for me with the sample provided

Capture.PNG

Not applicable
Author

here is a random screenshot from a chunk of my table.

test.PNG

sunny_talwar

Looks okay to me... not sure what issue you are running into....

Not applicable
Author

is there a way to troubelshoot the problem? I'm afraid it has something to do with the column field type.

Not applicable
Author

this also didnt work .. the problem seems to be trivial but weirdly not working