Qlik Community

Qlik Education Discussions

Discussion Board for collaboration related to Qlik Education.

Not applicable

Problem with aggr() function with if.

Hi there!

I'm having a Simple Table and on each line has different expressions. It controls what expressions goes to each line with a code:

if(Code_Dim_Fat='A001', <EXPRESSION_1>,

if(Code_Dim_Fat='A002', <EXPRESSION_2>,

  ... ))

So far, I have never used an expression in this table that contains an aggr() function. Now I need it, but doesn't work!!!!

if(Cod_Dim_Fat='A001',num(sum(aggr((sum({<%EmpresaID = {'J'}>} Metas_Fat_Reais) / ...), MesAno)),'#.##0,00'),

if(Cod_Dim_Fat='A002',num(sum(aggr((sum({<%EmpresaID = {'J'}>} Metas_Fat_Qt) / ..., MesAno)),'#.##0,00'),

))

The second expression ALWAYS return zero. I've tried to eliminate IF like this:

num(

sum(aggr((sum({<%EmpresaID = {'J'}, Cod_Dim_Fat = {'A001'}>} Metas_Fat_Reais) / ...), MesAno))

+

sum(aggr((sum({<%EmpresaID = {'J'}, Cod_Dim_Fat = {'A002'}>} Metas_Fat_Qt) / ..., MesAno))

,'#.##0,00')


But still doesn't work!!

Why does the AGGR() not work like that?

Thanks in advance!

Community Browser