Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
lee_williams
Contributor II
Contributor II

Pivot table totals incorrect

Hi All,

I have a pivot table which is pulling in data from a SQL table which is essentially showing a number of products as a dimension  and doing a count on the products across the year.

Now on our system we had to return a few of the products c  in June and this didn't show up in the original data as it only shows sales not returns. To get round this I put an extra line on the table as a placeholder and gave it a value of 1.

On creating the pivot I did a calculation in the expression ( see expression under table)

   

JanfebmarAprMayJunJulAugSep
product a111111
product b234333
product c22-4
product d111111
product e22222222
product f333333
total687111010953


if(match(Product,'product c') and Year = 2017 and Month = 6,count(distinct btlPOKeyCode) - 5, count(distinct btlPOKeyCode))

The result is that the table itself is showing exactly the numbers I want it to show with the -4 in june for product C , however , the totals are incorrect for this column and instead of using the -4 as specified it is using the original 1 placeholder , therefore instead of being 5 in the total it states 10.

I can't put extra data in the original import as the number is actually 3500 and I'd rather not another 3500 lines on the table so was looking at a simple way to do it post import.

Any ideas?

Cant attach original table , sorry

4 Replies
sunny_talwar

Try this

Sum(Aggr(If(Match(Product,'product c') and Year = 2017 and Month = 6, Count(DISTINCT btlPOKeyCode) - 5, Count(DISTINCT btlPOKeyCode)), Product, Month))

Anil_Babu_Samineni

May be this?

Sum(aggr(if(match(Product,'product c') and Year = 2017 and Month = 6,count(distinct btlPOKeyCode) - 5, count(distinctbtlPOKeyCode)), FieldDims))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
lee_williams
Contributor II
Contributor II
Author

Thank you both , worked perfectly

Anil_Babu_Samineni

You can spend time < 1 minute to close this thread by flag Correct Answer of Sunny's Response..

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful