Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Giovane
Creator
Creator

Unexpected Result in a Chart

Hi guys,

I'm facing a little tricky problem here. Please, follow the steps bellow to see my issue:

1.  I added values to the table MOVIMENTACOES as follow

[...]

VendasLiquidas:
LOAD
%EmpresaMesAno,
Sum(If(D|C = 'C',If((TIPONATOPER='S' /*Saídas*/ and EMITEDUPL='T' and MOVESTOQUE='T' and CODNATOPER <> '5.551.1' /*Venda do Ativo Imobilizado*/) and VENDAS.SITUACAO <> 'C'
or (%NatOperacao = '5.102.1' /*Vendas feitas no SB*/ or CODNATOPER = '5.103.1' or CODNATOPER = '6.103.1' or CODNATOPER = '5.103.2' or CODNATOPER = '5.401.2'
or CODNATOPER = '6.401.2' or CODNATOPER = '5.401.4' or CODNATOPER = '6.103.2' or CODNATOPER = '5.104.1' or CODNATOPER = '6.104.1'
or CODNATOPER = '5.104.2' or CODNATOPER = '6.104.2'/*Venda com Maifesto*/ or CODNATOPER = '5.103.3' or CODNATOPER = '6.103.3' /*CODNATOPER incluidos após atualizaão do sistema em Mai2021*/)
and VENDAS.SITUACAO <> 'C',VALOR/NumeroItensPorVenda)))
- Sum(If(%PlanoContas = 10,VALOR)) as VendasLiquidas
Resident
MOVIMENTACOES
Group By
%EmpresaMesAno;

Left Join (VendasLiquidas) LOAD
%EmpresaMesAno,
Mês,
Ano,
%Empresa,
'VL' as D|C,
10001 as %PlanoContas
Resident
MOVIMENTACOES;

Concatenate (MOVIMENTACOES) LOAD
%Empresa,
%PlanoContas,
Ano,
Mês,
D|C,
%EmpresaMesAno,
VendasLiquidas as VALOR
Resident
VendasLiquidas;

DROP Table
VendasLiquidas;

2.  The task worked well, as you can see bellow. When I select 2022 as Year (Ano) and jan as Month the amounts for each %Empresa are right

Giovane_0-1658261515372.png

3.  To confirm the accuracy of the above results I applied the expression bellow to first, all the %Empresa, from the second to the forth results, for %Empresa = 1, %Empresa = 4, %Empresa = 5. Everything worked as expected.

Giovane_1-1658261745251.png

=Sum(If(D|C = 'C',If((TIPONATOPER='S' /*Saídas*/ and EMITEDUPL='T' and MOVESTOQUE='T' and CODNATOPER <> '5.551.1' /*Venda do Ativo Imobilizado*/) and VENDAS.SITUACAO <> 'C'
or (%NatOperacao = '5.102.1' /*Vendas feitas no SB*/ or CODNATOPER = '5.103.1' or CODNATOPER = '6.103.1' or CODNATOPER = '5.103.2' or CODNATOPER = '5.401.2'
or CODNATOPER = '6.401.2' or CODNATOPER = '5.401.4' or CODNATOPER = '6.103.2' or CODNATOPER = '5.104.1' or CODNATOPER = '6.104.1'
or CODNATOPER = '5.104.2' or CODNATOPER = '6.104.2'/*Venda com Maifesto*/ or CODNATOPER = '5.103.3' or CODNATOPER = '6.103.3' /*CODNATOPER incluidos após atualizaão do sistema em Mai2021*/)
and VENDAS.SITUACAO <> 'C',VALOR/NumeroItensPorVenda))) - Sum(If(%PlanoContas = 10,VALOR))

4. Calling the numbers in a Pivot Table Chart, using the expression bellow, the problem appears!!!

Giovane_2-1658262158941.png

=Sum(If(D|C = 'C',If((TIPONATOPER='S' /*Saídas*/ and EMITEDUPL='T' and MOVESTOQUE='T' and CODNATOPER <> '5.551.1' /*Venda do Ativo Imobilizado*/) and VENDAS.SITUACAO <> 'C'
or (%NatOperacao = '5.102.1' /*Vendas feitas no SB*/ or CODNATOPER = '5.103.1' or CODNATOPER = '6.103.1' or CODNATOPER = '5.103.2' or CODNATOPER = '5.401.2'
or CODNATOPER = '6.401.2' or CODNATOPER = '5.401.4' or CODNATOPER = '6.103.2' or CODNATOPER = '5.104.1' or CODNATOPER = '6.104.1'
or CODNATOPER = '5.104.2' or CODNATOPER = '6.104.2'/*Venda com Maifesto*/ or CODNATOPER = '5.103.3' or CODNATOPER = '6.103.3' /*CODNATOPER incluidos após atualizaão do sistema em Mai2021*/)
and VENDAS.SITUACAO <> 'C',VALOR/NumeroItensPorVenda),
If(D|C = 'D',VALOR,
If(D|C = 'VL',VALOR))))

 

After many hours trying to solve the mystery I ask your help.

Any suggestion?

 

 

Labels (3)
0 Replies