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

Acumulado mensal

Boa tarde

Esta foi a forma que encontrei de trazer o valor acumulado do mês selecionado. Alguém teria alguma sugestão de como melhorar e simplificar, sem ser no script ???

IF(MES='01',SUM({1<PACOTE_C={"<12"},ATIVO_SN={"S"},ANO={"2012"},MES={"<02"}>}VL_GASTOS_ORC),

IF(MES='02',SUM({1<PACOTE_C={"<12"},ATIVO_SN={"S"},ANO={"2012"},MES={"<03"}>}VL_GASTOS_ORC),

IF(MES='03',SUM({1<PACOTE_C={"<12"},ATIVO_SN={"S"},ANO={"2012"},MES={"<04"}>}VL_GASTOS_ORC),

IF(MES='04',SUM({1<PACOTE_C={"<12"},ATIVO_SN={"S"},ANO={"2012"},MES={"<05"}>}VL_GASTOS_ORC),

IF(MES='05',SUM({1<PACOTE_C={"<12"},ATIVO_SN={"S"},ANO={"2012"},MES={"<06"}>}VL_GASTOS_ORC),

IF(MES='06',SUM({1<PACOTE_C={"<12"},ATIVO_SN={"S"},ANO={"2012"},MES={"<07"}>}VL_GASTOS_ORC),

IF(MES='07',SUM({1<PACOTE_C={"<12"},ATIVO_SN={"S"},ANO={"2012"},MES={"<08"}>}VL_GASTOS_ORC),

IF(MES='08',SUM({1<PACOTE_C={"<12"},ATIVO_SN={"S"},ANO={"2012"},MES={"<09"}>}VL_GASTOS_ORC),

IF(MES='09',SUM({1<PACOTE_C={"<12"},ATIVO_SN={"S"},ANO={"2012"},MES={"<10"}>}VL_GASTOS_ORC),

IF(MES='10',SUM({1<PACOTE_C={"<12"},ATIVO_SN={"S"},ANO={"2012"},MES={"<11"}>}VL_GASTOS_ORC),

IF(MES='11',SUM({1<PACOTE_C={"<12"},ATIVO_SN={"S"},ANO={"2012"},MES={"<12"}>}VL_GASTOS_ORC),

IF(MES='12',SUM({1<PACOTE_C={"<12"},ATIVO_SN={"S"},ANO={"2012"},MES={"*"}>}VL_GASTOS_ORC)))))))))))))

Desde já agradeço

Att

Rodrigo

1 Solution

Accepted Solutions
fernando_tonial
Partner - Specialist
Partner - Specialist

Olá, vc deve ter um campo com a Data e outro com um Flag informando que a data já passou e pode fazer assim:

Expressão.

SUM({$<PACOTE_C={"<12"},ATIVO_SN={"S"},ANO=,MES=, DATA={">=$(=YearStart(Max({<FlgRealizado={1}>} DATA)))<=$(=Max({<FlgRealizado={1}>} DATA))"}>} VL_GASTOS_ORC)

Campo Flag no Script.

If(Data<='$(vHoje)',1,0) as FlgRealizado,

Espero ter ajudado.

Tonial.

Don't Worry, be Qlik.

View solution in original post

5 Replies
fernando_tonial
Partner - Specialist
Partner - Specialist

Olá, vc deve ter um campo com a Data e outro com um Flag informando que a data já passou e pode fazer assim:

Expressão.

SUM({$<PACOTE_C={"<12"},ATIVO_SN={"S"},ANO=,MES=, DATA={">=$(=YearStart(Max({<FlgRealizado={1}>} DATA)))<=$(=Max({<FlgRealizado={1}>} DATA))"}>} VL_GASTOS_ORC)

Campo Flag no Script.

If(Data<='$(vHoje)',1,0) as FlgRealizado,

Espero ter ajudado.

Tonial.

Don't Worry, be Qlik.
Not applicable
Author

Bom dia Fernando.

Era isso, mesmo.. ficou perfeito..

Só mais uma duvida,

com esta formula, trarei o acumulado, tanto projetado como realizado até determinado mês.

Gostaria do seguinte.. ex: mês de Março

Acumulado Realizado até março + acumulado previsto de abril a dezembro..

É possível?

Desde já agradeço.

Not applicable
Author

Bem, acho que consegui.

Segue abaixo, se mais alguém precisar.

(SUM({<DT_ANO=,DT_MES=, DATA={">=$(=YearStart(Max({<FlgRealizado={1}>} DATA)))<=$(=Max({<FlgRealizado={1}>} DATA))"}>} VL_GASTOS_REAL)) // realizado até o mês selecionado (se mês selecionado abril, JAN a AGO)

+

(SUM({<PACOTE_C={"<12"}-{"7"},ATIVO_SN={"S"} ,DT_ANO=,DT_MES=, DATA ={">=$(=Min({<FlgRealizado={1}>} DATA)+1) <=$(=YearEnd(Min({<FlgRealizado={1} DATA)))"}>} VL_GASTOS_ORC)) // projetado do mês selecionado até o final do ano (SETa DEZ)


Ficou +ou- assim

Sem título.jpg


fernando_tonial
Partner - Specialist
Partner - Specialist

é possível sim. normalmente faço outro flag para isso.

If(Data>'$(vHoje)',1,0) as FlgProjetado

Onde a variável de vHoje é:

LET vHoje = Today();

Da forma que você fez funciona também.

Abraços.

Tonial.

Don't Worry, be Qlik.
Not applicable
Author

Obrigado Fernando.