Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sum december last year with current year months

hi guys

i have a table that contain this data

load * Inline

[Periodo,Month,Year, Value

'01/10/2012',10,2012,500

'01/11/2012',11,2012100

'01/12/2012',12,2012,200

'01/01/2013',01,2013,300

'01/02/2013',02,2013,400

'01/03/2013',03,2013,500];

is posible tu sum the value from december from 2012 to the next months in 2013?

for example.

01/01/2013 = 300 + 200 (01/12/2012) =500

01/02/2013 = 400 + 200 (01/12/2012) =600

i need to put this data in a straight table with month as  dimension (only 2013 data)

i try to do this

sum({<Periodo={'>$(=makedate(year(today())-1, 12))'}>}Value)

  +  sum({<Periodo={'$(=makedate(year(today())-1, 12))'}  >}Value)

but the problem is that not sum the value in the same month, my table looks like

PeriodoValue
01/12/2012200
01/01/2013300
01/02/2013400
01/03/2013500
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hello Jorge,

Since the Período Column is used, it can not set another Período in the same row.

To accomplish what you want, you should create a variable that returns sum of the last month of the past year, as in :

vSum = (  {<Periodo = { '$(=Date( Addmonths( Max( Periodo ) , -1*(Num(  Month( Max(  Periodo ) ) ) ) ) ))' } >} Value )

And them use Value + vSum

So the results are:

PeriodoSum + Dec 2012Sum
01/01/2013500300
01/02/2013600400

  01/03/2013

700500

See the soliton Attached.

hope I could help.

View solution in original post

3 Replies
Anonymous
Not applicable
Author

Hello Jorge,

Since the Período Column is used, it can not set another Período in the same row.

To accomplish what you want, you should create a variable that returns sum of the last month of the past year, as in :

vSum = (  {<Periodo = { '$(=Date( Addmonths( Max( Periodo ) , -1*(Num(  Month( Max(  Periodo ) ) ) ) ) ))' } >} Value )

And them use Value + vSum

So the results are:

PeriodoSum + Dec 2012Sum
01/01/2013500300
01/02/2013600400

  01/03/2013

700500

See the soliton Attached.

hope I could help.

Gysbert_Wassenaar

The problem you're running into is described in this document: Calculating rolling n-period totals, averages or other aggregations. It also has a possible solution.


talk is cheap, supply exceeds demand
Not applicable
Author

thanks  lukas for your answer, it really helpful, i'll apply your solucion in my app