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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Aggr Count Help

Hi all,

I need an help with Aggr count, I have attached a sample & explained my requirement.

Thanks In Advance

14 Replies
rbecher
MVP
MVP

You cannot break out of the dimension context (Brand).

Maybe the only solution is a precalculation of this figure as @nmartin wrote...

Astrato.io Head of R&D
johnw
Champion III
Champion III

This seems to do the trick.

sum(aggr(count({<"BRAND ID"=>} total <"ACCT"> distinct "BRAND ID"),"BRAND ID","ACCT"))

Edit: Added set analysis to fix bug where if you selected a single row, the value changed.

rbecher
MVP
MVP

This is brilliant John!

How can this count work with a different dimensionality?

Astrato.io Head of R&D
Not applicable
Author

Thanks John... Perfect that's what I am looking for....

johnw
Champion III
Champion III

@TIQView - Ralf Becher wrote:

How can this count work with a different dimensionality?

Well, ignore the sum(), replace the aggr() with a table, and get rid of the set analysis for the moment.  That gives us this hopefully more understandable case:

dimension 1 = BRAND ID
dimension 2 = ACCT

expression  = count(total <"ACCT"> distinct "BRAND ID")

That's exactly how I started.  Now, I wasn't certain it would work, but I thought it might, and it did.  What seems to be happening is that since we have account after brand in the dimensions, we only look at the accounts for the brand for that row.  However, in the count(), we tell it 'total <"ACCT">', which says to ignore the brand.  It ends up paying attention to the brand for the selection of accounts, but then ignoring the brand for the count of brands.  That's exactly what we needed.  Then it's just a matter of converting this temporary table into an aggr() by putting our two dimensions in the aggr(), summing up, and finally using set analysis to make sure that when we select one specific brand, it doesn't only count that brand.