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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
wanyunyang
Creator III
Creator III

Count(total) and sum(aggr(count()))

Hi guys,

 

I have data like this:

rep:
load * Inline
[
SalesRep, Customer, ZipCode, County
M, A, 00011, NY
M, A, 00022, NY
M, A, 00033, NY
M, A, 00044, NY
M, A, 00055, CA
M, D, 00099, NY
N, B, 00066, NY
N, C, 00077, CA
N, A, 00088, CA
];

 

I got a pivot table with dimensions: SalesRep - County  - Customer. In one of my measures, I need to show total numbers of zip codes for each Customer, regardless of SalesRep and County. (That would be: A - 6, B - 1, C - 1, D - 1).

 

I'm trying to use:  sum(aggr(count(ZipCode),Customer)), but it's not giving me correct numbers. However,  Count(total <Customer> ZipCode) gives correct result. I'm wondering why the first one doesn't work but the second one does. Screenshot below with both expressions. Any advice helps! Thanks!

 

a.PNG

1 Reply
pradosh_thakur
Master II
Master II

try the below might work for you 

aggr(nodistinct count(ZipCode),Customer)

 

About why the first code works, that's due to the total qualifier you have used. More about total .

https://community.qlik.com/t5/Qlik-Design-Blog/What-does-the-TOTAL-qualifier-do/ba-p/1472990

 

-Pradosh

Learning never stops.