Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Total expression in Pivotant Table with aggr

Hi there,

We're trying to get total expression results for this formula:

Count(DISTINCT(CUSTOMER)) / CORRECTION_FACTOR

CORRECTION_FACTOR is a number that depends on CENTER and BRAND.

Applying the formula directly, we get these resutls:error loading image

It doesn't consolidate for center and brand.

I guess I need to use an aggr function to consolidate, but if I use this formula:

Sum( Aggr( Count (DISTINCT CUSTOMER) / CORRECTION_FACTOR, BRAND, CENTER))

Then the values are not distributed correctly among the AXIS (or any other dimension in the table):

error loading image

If I add the dimension into the aggr formula, then the values are distributed correctly among the AXIS but the totals are not correct.

Any help or clue on what I'm doing wrong?

Thank you!

1 Solution

Accepted Solutions
Not applicable
Author

IF(dimensionality ( )=1 OR dimensionality ( )=0 ,Sum( Aggr( Count (DISTINCT CUSTOMER)/CORRECTION_FACTOR, BRAND, CENTER)), Count (DISTINCT CUSTOMER)/CORRECTION_FACTOR)

B.R.

Önder

View solution in original post

6 Replies
danielrozental
Master II
Master II

I think you need to add AXIS to the aggr dimensions

Sum( Aggr( Count (DISTINCT CUSTOMER) / CORRECTION_FACTOR, AXIS, BRAND, CENTER))



Anonymous
Not applicable
Author

But if I do that, then it won't do the COUNT DISTINCT when consolidating for BRAND and CENTER, so the results won't be accurate. I mean, if there's the same customer in two AXIS, it will be counted twice when consolidating for CENTER.

danielrozental
Master II
Master II

can you try building a sample app for us to look at?

Anonymous
Not applicable
Author

Sure. You may download it from here

As you can see in the app, the column named "Aggr No Axis" have correct totals, but the values are wrongly distributed among the AXIS.

However, when you add the AXIS to the aggr, the totals are wrong, since the expression just adds the values. I guess I need some other function before the aggr, but I fail to know what to use.

By the way, thank you so much for your help.

Not applicable
Author

IF(dimensionality ( )=1 OR dimensionality ( )=0 ,Sum( Aggr( Count (DISTINCT CUSTOMER)/CORRECTION_FACTOR, BRAND, CENTER)), Count (DISTINCT CUSTOMER)/CORRECTION_FACTOR)

B.R.

Önder

Anonymous
Not applicable
Author

YES! THAT'S IT!

Thank you so much!! 😄