Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
deekey2
Contributor
Contributor

Calculate Column % in Pivot Table

Hi All,

I have a table as below:

Category Type QTY
A D 10
A E 12
B F 20
B D 30
C E 40
C F 50
A D 60
A E 120
B F 90
B D 50
C E 90
C F 200

 

And I made a pivot table (X:Type / Y:Category) , which sum the QTY like this:

  D E F
A 70 132  
B 80   110
C   130 250

 

Then I would like to convert as %  by each column.

  D E F
A 47% 50% 0%
B 53% 0% 31%
C 0% 50% 69%

 

I tried to use: sum(QTY) / sum(total QTY)

but the part "sum(total QTY)" returns 772 (total of all QTY)

 

I tried and worked for hard code like:

sum(TOTAL if(Type='D', QTY)),

but if I get dynamic like:

sum(TOTAL if(Type=subfield(type,',',1), QTY))

it returns 772 again..

 

Any ideas? thanks

1 Solution

Accepted Solutions
MayilVahanan

Hi 

Try like below

sum(QTY) / sum(total<Type> QTY)

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

1 Reply
MayilVahanan

Hi 

Try like below

sum(QTY) / sum(total<Type> QTY)

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.