Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

stacked bar with aggr in dimension

Hi,

I have this in dimension for stack bar.

=AGGR(sum(NUMBER) ,CLASS ,MONTH)

then in expression i have,

COUNT(AGGR(sum(NUMBER) ,CLASS ,MONTH))

the result of dimension will be 0, 1, 2.

the expression is couting, how many of 0, how many of 1, and 2.

couting is fine, but when i turn it to percentage, it wont work.

i have tried relative, etc... i need to get the sum of the count, but with the aggr in dimension always showing, i can't get the total.

i have also tried to split the count, but there's no result

if( (AGGR(sum(NUMBER) ,CLASS ,MONTH))=0, count(AGGR(sum(NUMBER) ,CLASS ,MONTH)) )+

if( (AGGR(sum(NUMBER) ,CLASS ,MONTH))=1, count(AGGR(sum(NUMBER) ,CLASS ,MONTH)) )+

if( (AGGR(sum(NUMBER) ,CLASS ,MONTH))=2,count(AGGR(sum(NUMBER) ,CLASS ,MONTH)) )

any hints?

Thanks,

1 Solution

Accepted Solutions
Jason_Michaelides
Luminary Alumni
Luminary Alumni

Woohoo! After about 6 attempts I got a post past the bloody moderator rules!  It seems your full field name for CLASS sets off alarms!

Fuller explanation coming once it gets approved...

View solution in original post

19 Replies
Jason_Michaelides
Luminary Alumni
Luminary Alumni

Just thinking out loud really - need to test it, but could you divide by the same Aggr() without one of the dimensions in it? Or maybe use TOTAL in the denominator expression.

Not applicable
Author

yup.. i tried all those possible ways i could think of... and i'm still thinking ...

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Can you post your app?

Not applicable
Author

Hi Jason,

here is it, instead of showing count figures. i am trying to make 100% stacked bar chart. normally it's easy. but with aggr in dimension, it becomes tricky.. for me...

thanks for your help.

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Will take a look this evening when I get back mate.

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Hi Nick,

Sorry - I only got to look at this this morning.  Your expression (and dynamic dimenasion) aggregate over MONTH and CLASS.  You have MONTH as a dimension, therefore your divider needs to be a TOTAL count of CLASS.  Try this:

COUNT(aGGR(sum(FP_NB_COUNTER) ,PC_CLASSI_LABEL,MONTH_YEAR))/COUNT(TOTAL DISTINCT PC_CLASSI_LABEL)

Seems to work.

Hope this helps,

Jason

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Does everything I type need moderator approval!?

Jason_Michaelides
Luminary Alumni
Luminary Alumni

I guess not...

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Divide your expression by:

COUNT(TOTAL DISTINCT PC_CLASSI_LABEL)