Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Valor acumulado por produto

Boa tarde,

Por gentileza poderiam me ajudar?

Preciso incluir na minha tabela dinâmica duas colunas contendo as seguintes informações:

1º Um acumulado linha por linha (somar a linha de cima com a linha debaixo e assim sucessivamente) de um grupo, no próximo grupo essa soma deve zerar e recomeçar o acumulado,  grupo por grupo exemplo na imagem.

2º Em outra coluna preciso saber o acumulado em porcentagem.

Obrigada!valor acumulado.png

1 Solution

Accepted Solutions
Thiago_Justen_

Marilda,

Uma solução via script:

Vendas_Temp:

LOAD

    Grupo,

    "Valor

Total" as Valor_Total,

    "%

(Acumulativo)" as %_Acumulado

FROM [lib://Downloads/Duvida valor acumulativo.xlsx]

(ooxml, embedded labels, header is 1 lines, table is [1º]);

Vendas:

LOAD

*,

    If(Grupo=Peek(Grupo),NumSum(Valor_Total,Peek('Acumulado')),Valor_Total) as Acumulado

RESIDENT  Vendas_Temp Order By Grupo,Valor_Total;

DROP TABLE Vendas_Temp;

Resultado:

Capturar.PNG

Ou via UI:

Expressão:

If(Top(Grupo)=Grupo,RangeSum(Above(total Valor_Total,0,RowNo(total))))

Resultado:

Capturar.PNG

O mesmo raciocínio se aplica para o % acumulado.

Abs e Sucesso!!

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

View solution in original post

4 Replies
Thiago_Justen_

Marilda,

Uma solução via script:

Vendas_Temp:

LOAD

    Grupo,

    "Valor

Total" as Valor_Total,

    "%

(Acumulativo)" as %_Acumulado

FROM [lib://Downloads/Duvida valor acumulativo.xlsx]

(ooxml, embedded labels, header is 1 lines, table is [1º]);

Vendas:

LOAD

*,

    If(Grupo=Peek(Grupo),NumSum(Valor_Total,Peek('Acumulado')),Valor_Total) as Acumulado

RESIDENT  Vendas_Temp Order By Grupo,Valor_Total;

DROP TABLE Vendas_Temp;

Resultado:

Capturar.PNG

Ou via UI:

Expressão:

If(Top(Grupo)=Grupo,RangeSum(Above(total Valor_Total,0,RowNo(total))))

Resultado:

Capturar.PNG

O mesmo raciocínio se aplica para o % acumulado.

Abs e Sucesso!!

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

Boa tarde Thiago,

Utilizei a expressão e deu certo, porem ele não zera a soma quando troca o grupo conforme imagem.

Acumulativo.png

Preciso que zerasse como nesse exemplo na coluna valor total (acumulativo):

valor acumulado.png

Poderia me ajudar?

Thiago_Justen_

Marilda, existe a possibilidade de você calcular direto no script?

Se sim, isso resolve:

Vendas_Temp:

LOAD

    Grupo,

    "Valor

Total" as Valor_Total,

    "%

(Acumulativo)" as %_Acumulado

FROM [lib://Downloads/Duvida valor acumulativo.xlsx]

(ooxml, embedded labels, header is 1 lines, table is [1º]);

Vendas:

LOAD

*,

    If(Grupo=Peek(Grupo),NumSum(Valor_Total,Peek('Acumulado')),Valor_Total) as Acumulado

RESIDENT  Vendas_Temp Order By Grupo,Valor_Total;

DROP TABLE Vendas_Temp;

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

Bom dia Thiago,

Não consegui seguir o mesmo raciocínio para a questão da %, preciso que a porcentagem seja na escala de 0% a 100%.

Por gentileza, poderia me ajudar?