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: 
mikegrattan
Creator III
Creator III

RangeSum cumulative total does not match actual data

I'm working with the following table:

mikegrattan_2-1679006068445.png

 

The goal is to get the cumulative total number  to match the sum of the actual Qty Shipped column.  Is that possible?  Here is the expression for the cumulative column:

Aggr(RangeSum(Above(sum(EquivalentQuantity),0,RowNo())),
(CommodityCode,(Numeric,Ascending),(Text(Ascending)),
(StartOfWeek), (Numeric, Ascending), (Text, Ascending)),
(ShipDate, (Numeric, Ascending), (Text, Ascending)))

Labels (1)
1 Solution

Accepted Solutions
mikegrattan
Creator III
Creator III
Author

Marcus,

It looks like my edited comment didn't get saved last night.  I tried with Total as well and got the same results.  However, I did discover that there's a Modifier option that I overlooked before.  Once I set that to Accumulation, I got the correct results but they are in reverse order. Note that the Modifier option created a new expression:

Aggr(RangeSum(Above(Total ( aggr(RangeSum(Above(sum(EquivalentQuantity),0,RowNo())),ShipDate,CommodityCode) ) , 0, 6)),
[$(=Replace(GetObjectField(1),']',']]'))], ([$(=Replace(GetObjectField(0),']',']]'))], (Numeric, Descending)))

I changed the sort to Ascending and got the correct results:

mikegrattan_5-1679498683151.png

 

 

View solution in original post

12 Replies
marcus_sommer

Did you try it without the aggr() stuff, just?

RangeSum(Above(sum(EquivalentQuantity),0,RowNo()))

mikegrattan
Creator III
Creator III
Author

Hi Marcus,

Here are the results when I remove the aggr():

mikegrattan_0-1679325032307.png

 

I'm filtering on one week.  My understanding is that the aggr() is needed, along with the dimension sorting, in order to get a cumulative total by week.  Thanks.

 

marcus_sommer

It depends in regard to the used dimensions within the chart and the default-ordering of the object. Regarding to your first screenshot it looked that a normal cumulation-calculation might be usable. Before looking further add a TOTAL to the above and see if it changed the results. 

mikegrattan
Creator III
Creator III
Author

The expression now looks like this:

RangeSum(Above(Total sum(EquivalentQuantity),0,RowNo()))

But the numbers look exactly the same as they did without the Total.  I am currently filtering on a single week and a single CommodityCode; same as last scree shot.

 

marcus_sommer

The expression sum(EquivalentQuantity) is the same as QTY Shipped or is it different?

mikegrattan
Creator III
Creator III
Author

Yes, I'm just using a different label for the table column.

marcus_sommer

I wouldn't expect such behaviour by a "classical" data-structure - in data-model + object-design. Therefore I suggest to re-create the object from the scratch and step by step. At first with one dimension and the normal sum() + rangesum(above(sum())) without any further measures in regard to sorting, coloring and so on (regardless if fixed set or calculated) or alternate states and similar stuff. 

It will exclude any possible corruption of the object and showing which measure leads to the seen behaviour. Just a guess - the cause may a calculated dimension ....

mikegrattan
Creator III
Creator III
Author

I started over and it still looks like it won't accumulate correctly.  Just using the basics; I selected one commodity, LTC, and one week of data.  There are no calculated dimensions.  I changed the label for Shipped Qty so it reflects the name of the measure more precisely, so now it's labeled Equiv Qty.   I tried with and without Total in the expression but I'm getting the same results:

Cumulative: RangeSum(Above(sum(EquivalentQuantity),0,RowNo()))

mikegrattan_0-1679439146080.png

 

marcus_sommer

Please try it again with: RangeSum(Above(TOTAL sum(EquivalentQuantity),0,RowNo()))