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: 
BoXiangWang
Contributor III
Contributor III

Rolling Sum in Stacked Bar Chart

Hi all QS experts,

I have an issue with the rolling 12 month bar chart.

After applying the expression below, I found there are two issues:

(1) It doesn't roll up, as you can see there are 0s in certain months
(2) The accumulation figures will change depending on the Dimension user selected
 
(1) 0s showing in the bar chart
BoXiangWang_0-1740459028493.png

 

(2) After changing the dimension to B, the 2024-Dec number becomes 31, instead of 27, which 27 is accurate

BoXiangWang_1-1740459074580.png

 

Could you help check where could be the problem? I really don't get it.
 

Expression
=
IF(date_month<'$(=AddMonths(min(date_month),($(vRollingMonths)-1)))', null(),
 
{<[date_month]={"<=$(=MonthEnd(vRollingDate))"}>}
aggr(
Rangesum(Above(Count(Distinct {<leaver={1}, secondee=$(vSecondee)>} [dim_ppl_employee_sk]), 0, $(vRollingMonths)))
    ,$(vDimensionTurnover), date_month)
 
)
Labels (2)
1 Reply
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

I believe the problem is related to using the Above() function in a multi-dimensional chart (or AGGR, for that matter). By default, the Above() function works within the "current segment" of the two dimensions. In order to make it work across multiple dimensions, add the TOTAL qualifier to the Above().

Another possible issue is the inner Set within the AGGR, which is not repeated outside of the AGGR. Based on the logic of your formula, you should add the Set defined in the Count function, to the outer set that you specify before the AGGR - then it will apply correctly to the whole calculation.

Other than that, there could be errors with variables, field names, etc... - it's hard to predict all the possible issues without seeing the App.

Cheers,