Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
nareshthavidishetty
Creator III
Creator III

Totals not correct

Hi,

I have used pivot table but the totals are not matching.Below is the expression.

Expression:

if(sum(total_dec_app) > sum(aggr(sum(customer_id_count),store)),sum(total_dec_app) - sum(aggr(sum(customer_id_count),store)),0)

Below is the image for reference.

Untitled.png

Thanks..

7 Replies
Anil_Babu_Samineni

When you say Total is not matched, You may describe more. And then, I would recommend to share sample data and expected output which demonstrates the issue

Expression seems okay to me

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
nareshthavidishetty
Creator III
Creator III
Author

Yes the total is not matching..

PrashantSangle

Hi,

try below.

1: sum(aggr(sum(if(total_dec_app > customer_id_count,total_dec_app - customer_id_count,0),store))

or
2: if(sum(total_dec_app) > sum(aggr(sum(customer_id_count),store)),sum(aggr(sum(total_dec_app),store)) - sum(aggr(sum(customer_id_count),store)),0)

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
HirisH_V7
Master
Master

Hi,

Can you post your sample data and elaborate your requirement.

I suggest to use dimensionality() for the totals fields. It will be helpful for grouping and using aggr efficiently in pivot.

-Hirish

HirisH
“Aspire to Inspire before we Expire!”
satheshreddy
Creator III
Creator III

Hi Naresh,

can you check the below EXP.

if(sum(total_dec_app) > aggr(sum(customer_id_count),store),sum(total_dec_app) - aggr(sum(customer_id_count),store),0)

Regards

Sathish

Not applicable

Hi,

It is a bad approach to use if statements in your expressions as it is killing the app performance. Looking at the expression it might work as per design.

Please create a copy of your table and remove the store dimension. Then you will likely see the subtotals as you currently see.

Also you can add two expressions to see the behavior of the complete formula.statement. Expression 1 only contains: sum(total_dec_app). expression 2 contains sum(aggr(sum(customer_id_count),store)).

Kind regards,

Matthijs

sunny_talwar

How many dimensions do you have in your pivot table? Just 1 or are there more?