Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Not applicable

Cumulative Sum Based on Dimensions

Hello, i was searching for answers to a problem I'm trying to solve, but I could not do it with what I found. So here is my question.

I have 3 dimensions, Filial, Data and Codigo_Produto. For those 3, there is the field QTDE_ENTRADA, that can be seen on the fourth column ( entradas ). This column is a basic sum ( Sum(QTDE_ENTRADA) ).

Then I have the last column that should be a cumulative column. Basically, it should respect the FILIAL and CODIGO_PRODUTO columns and consider all the previous or equal date in DATA column.

So for example, the third line should be a sum considering FILIAL and CODIGO_PRODUTO with all the values <= DATA field. So, since third line DATA is "18/12/2014", it should cumulate everything equals or previous than itself (18/12/2014,12/09/2014,12/04/2014)

Second line should cumulate itself and previous dates in DATA columns as well (12/09/2014,12/04/2014)...

Print.PNG

I don't know if I could make myself clear, I apologize for my English.

Thanks in advance for the help.

Tags (1)
6 Replies

Re: Cumulative Sum Based on Dimensions

Demote the DATA dimension to last place (i.e. to the third column) and use rangesum(aggr(sum(QTDE_ENTRADA),0,rowno())) as expression.


talk is cheap, supply exceeds demand
Employee
Employee

Re: Cumulative Sum Based on Dimensions

How about  the following to add up current and previous rows ?  sum(Sales) is the basic expression 

rangesum( above(  sum(Sales),0,RowNo()))

Not applicable

Re: Cumulative Sum Based on Dimensions

Hi Gysbert, I tried this one but it resulted on 0 for the whole column. I just demoted the column as you told me and tried to use expression.

Not applicable

Re: Cumulative Sum Based on Dimensions

Hi, Jonathan. Uhm... not sure if I can count on current and previous rows to sum. For example let's suppose I filter my table by an specific date on DATA column, the third for example. Cumulative column should still give me 6. with this expression, the result resets to 2, which is it's own value only, and not a cumulative answer. Is there anyway to cumulate even when filtering ? Thanks

Employee
Employee

Re: Cumulative Sum Based on Dimensions

Ok.  I made an adjustment to disregard a specific filter.  Here is the if() expression combined with the rangesum()

if( substringcount(Concat(Year,'-'),Year),

rangesum( above(  sum( {$<Year=>} Sales),0,RowNo())))

Capture.PNG

Capture2.PNG

alibd225
Contributor

Re: Cumulative Sum Based on Dimensions

In acceding order it's working fine, but in in descending order it's not working.

please help me to in descending order because we have 10 years information and i need to display last year cumulative value

Community Browser