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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to Sum Column(with condition) in Pivot Table

Hi,

     I've tried to search around this forum but I can't find a solution (or may be I need more detailed guidance) in order to solve my problem.

     Refer to the table below, I would like to get the data in red text.

    

NameClassMath ScoreScience Score
StudentAB2040
StudentBD1030
StudentCB3020
StudentDD2010
Total Score for Class B 5060
Total Score for Class D 3040

     I've also attached a sample QV application. Hope someone experienced can show me the changes in the application and re-attach the application.

     Thanks in advance and have a nice day.

6 Replies
calvindk
Creator III
Creator III

Try "show partial sums" on the presentation tab, and change dimension to have class first, student after.

That would look like this:

Not sure if that is good enough?

Anonymous
Not applicable
Author

Hi Anders Møller,

     I've tried your steps, to show partial sums for 'Class' on the presentation tab, then moved the 'Class' to become the first dimension, but I can't get the same result. Did i left out anything?

Sokkorn
Master
Master

Hi,

Let do this

1. Change expression

    [Math Score] to Sum([Math Score])

    [Science Score] to Sum([Science Score])

2. Drag [Class] field to first column and [Name] should be second column. Table header like this

    Class    Name    Sum([Math Score])    Sum([Science Score])

3. Goto Presentation -> Select "Name" dimension -> Check Show Partial Sums

Untitled.png

See sample attached file

Regards,

Sokkorn

Anonymous
Not applicable
Author

Hi Sokkorn Cheav (Cambodia),

     Thanks for the prompt reply. It's a good idea. But your solution will give me something like this:

ClassNameMath ScoreScience Score
BStudentA2040
StudentC3020
Total Score for Class B5060
DStudentB1030
StudentD2010
Total Score for Class D3040

     But for my case, I need the data to be all sorted by 'Student Name', while the solution that you suggest me is firstly sort by 'Class', then sort of 'Student Name'. I would need something exactly like below (if possible):

NameClassMath ScoreScience Score
StudentAB2040
StudentBD1030
StudentCB3020
StudentDD2010
Total Score for Class B
5060
Total Score for Class D
3040

     Hope to hear from someone who can help me. Thanks in advance!

Anonymous
Not applicable
Author

Hi All,

     Hope someone can give me some idea on this question. Your help is greatly appreciated.

     Thanks in advance.

Not applicable
Author

Why not create a new expression and add your set analysis. A bit messy but effective.