Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
fdemolin
Contributor II
Contributor II

Soma dos valores anteriores de um campo

Boa tarde,

Estou com um desafio,

Tenho a seguinte tabela:

LOAD * inline [

"Seq","Valor"

1,1

2,1

3,1

4,2

5,2

];

Gostaria de adicionar uma coluna através do data loader que calcula-se a soma dos valores anteriores para cada linha da tabela.

Exemplo:

"Seq","Valor","Acumulado"

1,1,1 (1)

2,1,2 (1+1)

3,1,3 (1+1+1)

4,2,5 (1+1+1+2)

5,2,7 (1+1+1+2+2)

1 Solution

Accepted Solutions
Thiago_Justen_

Pode usar o script:

LOAD

Seq,

Valor,

If(Seq=1,Valor,RangeSum(Valor,Peek(Acumulado))) as Acumulado;

LOAD * inline [

"Seq","Valor"

1,1

2,1

3,1

4,2

5,2

];

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago

View solution in original post

3 Replies
Thiago_Justen_

Pode usar o script:

LOAD

Seq,

Valor,

If(Seq=1,Valor,RangeSum(Valor,Peek(Acumulado))) as Acumulado;

LOAD * inline [

"Seq","Valor"

1,1

2,1

3,1

4,2

5,2

];

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago
nicolett_yuri

Thiago_Justen_

Resultado do script acima:

Capturar.PNG

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago