Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
chris1987
Creator
Creator

Pivot Table Total - Correct until collapsed

Hi,

I have a pivot table that has a function to calculate each line - which works Perfect when expanded but when the group is collapsed the value changes. I know why this is, it's because all of the values are rolled up on the subtotal row and then the logic is applied on to this new row.

e.g.

Expanded:

CustomerItem2017 Sales2018 SalesLike for Like (Formula)Like for Like (Value)
Cust112345£1000£2000=if(not isnull([2017 Sales]) and not isnull([2018 Sales]),[2018 Sales],null())£2000
98765-£1000

=if(not isnull([2017 Sales]) and not isnull([2018 Sales]),[2018 Sales],null())

54321£500£500

=if(not isnull([2017 Sales]) and not isnull([2018 Sales]),[2018 Sales],null())

£500
99999£200-

=if(not isnull([2017 Sales]) and not isnull([2018 Sales]),[2018 Sales],null())

So you can see that when the group is expanded that in the "Like for Like Value" column the total is £2500, but when you collapse it you get the following:

Collapsed:

CustomerItem2017 Sales2018 SalesLike for Like (Formula)Like for Like (Value)
Cust1£1700£3500=if(not isnull([2017 Sales]) and not isnull([2018 Sales]),[2018 Sales],null())£3500

I need to find a way to keep the £2500 when the row is collapsed. I was thinking aggr() but I'm a bit unsure how to do this.

Any help would be appreciated

Cheers

Chris

4 Replies
thevingo
Creator
Creator

I guess, because your IF conditions work at Summary-level & not at detail/row-level.

That's why 2018 sales for item 98765 is also added to the Total

thevingo
Creator
Creator

try SET expression

olivierrobin
Specialist III
Specialist III

hello

maybe you couls try

sum(=if(not isnull([2017 Sales]) and not isnull([2018 Sales]),[2018 Sales],0)

chris1987
Creator
Creator
Author

Thanks, I agree this is why it's happening but don't think SET expression will fix it? I need this to be dynamic as the user can select different period using filters etc.