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: 
fkeuroglian
Partner - Master
Partner - Master

Acumulate values using peek

Hi Expert

I want to use the peek function to acumulutae values in the script, and if i do not have value to one month, take the acumuluate and create a value that bring the previous (peek) value that i have in the table

for example

Retail   01-2010   100

Retail   02-2010   0

Retail   03-2010   50

Bank    01-2010   140

Bank    02-2010   0


I want something like this


Retail   01-2010   100

Retail   02-2010   100

Retail   03-2010   150

Bank    01-2010   140

Bank    02-2010   140


i attached and image that i have result and the qvd is simple only few register and field


i am using the peek, but i am sure i have an errror


thank you a lot


Fernando K.


1 Solution

Accepted Solutions
sunny_talwar

This may be:

Table:

LOAD Date(Date#(%MesAño, 'MM-YYYY'), 'MM-YYYY') as %MesAño,

    Actividad,

    SuperficieTotalxActividad

FROM

ValuesAcumulate.qvd

(qvd);

Join (Table)

LOAD Actividad,

  %MesAño,

  If(Actividad = Previous(Actividad), RangeSum(Peek('Test'), SuperficieTotalxActividad), SuperficieTotalxActividad) as Test

Resident Table

Order By Actividad, %MesAño;

View solution in original post

2 Replies
sunny_talwar

This may be:

Table:

LOAD Date(Date#(%MesAño, 'MM-YYYY'), 'MM-YYYY') as %MesAño,

    Actividad,

    SuperficieTotalxActividad

FROM

ValuesAcumulate.qvd

(qvd);

Join (Table)

LOAD Actividad,

  %MesAño,

  If(Actividad = Previous(Actividad), RangeSum(Peek('Test'), SuperficieTotalxActividad), SuperficieTotalxActividad) as Test

Resident Table

Order By Actividad, %MesAño;

Mark_Little
Luminary
Luminary

Hi,

IF(ROWNO()=1,

      Value,

      Peek(total,-1)+ (total)

      )  as total

Mark