Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
newuser
Creator II
Creator II

Pivot Totals Incorrect When Rows Collapsed

Hello - the measure expression below in my pivot table only works when all 3 dimensions are expanded. When the dimensions are collapsed, the total is just a grand total, without the set analysis invoked. Any ideas how to fix? I tried Dimensionality() but didn't work.

The 3 dimensions used are main, Region, and Branch below. The pivot table is grouped by Region, Branch, and main (in that order).  "yr" and "method2" are the columns of the pivot table (in that order). Thanks

 

=if(Dimensionality()<= 2 ,count(
aggr(count(( IF(
 Aggr(distinct
     sum({<method2={'Web'}>}totalpmt)/Sum(total <main, [yr], [Region] , [Branch]> totalpmt)
 main,yr, [Region], [Branch])>=$(UsageAbove),
1))
),main, [Region], [Branch], yr)),  1                  

)

2 Replies
ashishkalia
Partner - Creator
Partner - Creator


Create a variable and store:
vVariable = Sum(total <main, [yr], [Region] , [Branch]> totalpmt)

Set Expression:

 

SUM(
IF(
Aggr(
sum({<method2={'Web'}>}totalpmt)/$(vVariable)
,main,yr, [Region], [Branch]
)
>=$(UsageAbove),1)
)

newuser
Creator II
Creator II
Author

For some reason, the totals look correct (collapsed or expanded rows) when I used this simpler express below. How does one know to use AGGR in the measure vs. when not to use AGGR in a measure? Thanks

 

=sum({<pay_method2={'Web'}>}totalpmt)