Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
lionking15
Creator
Creator

Customizing Pivot table partial Sum

Hi Guys

Sno Name Sales
Q1Jan10
Feb20
Mar30
Total 60
Q2Apr40
May50
Jun60
Total 150

I want above pivot table as

Final Output

Sno Name Sales
Q1Jan10
Feb20
Mar30
Total 30
Q2Apr40
May50
jun60
Total 60

Total should be equal to max month of particular quarter.

1 Solution

Accepted Solutions
sunny_talwar

Try this expression:

=If(Dimensionality() = 1, FirstSortedValue(Aggr(Sum(Sales), Sno, Name), -Aggr(Name, Sno, Name)), Sum(Sales))

Capture.PNG

View solution in original post

5 Replies
sunny_talwar

Try this expression:

=If(Dimensionality() = 1, FirstSortedValue(Aggr(Sum(Sales), Sno, Name), -Aggr(Name, Sno, Name)), Sum(Sales))

Capture.PNG

vishsaggi
Champion III
Champion III

May be try this in your expression:

= IF(Dimensionality() = 1,  Max(Sales), Sum(Sales))

sunny_talwar

What if the Max sales was associated with the month of Jan? I think the sample data might make us think that Max(Sales) will work, but in reality if we wish to pick the sales associated with Max month, we need to use FirstSortedValue here

vishsaggi
Champion III
Champion III

I got it now. You are right. We need firstsorted value.

vinieme12
Champion III
Champion III

or this

=If(Dimensionality() = 1,Sum({<Name = {"=Name = AGGR(Max(TOTAL <Sno> Name),Sno,Name)"}>}Sales) , Sum(Sales))

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.