Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

fonsosurfer
New Contributor

Count condition error: nested aggregation not allowed

Hello!

I'm trying to count all the departaments that satisfies a condition. This is the condition:

if(( AVG(STANDAR_COST)

-

((NUM(SUM({<MONTH={$(=NUM($(=MAX({<ID_CLASS={$(Total_Cost)}>}MONTH)),'00'))}>} BENEFIT) /

       SUM({<MONTH={$(=NUM($(=MAX({<ID_CLASS={$(Total_Cost)}>}MONTH)),'00'))}>} HOURS),'###.##0,00'))

))<0,1,0)

Now I would have to get a number that indicates the number of the departaments that satisfies that condition. So I'm doing something like this:

=count({<Departament>} if(( AVG({<Departament>}STANDAR_COST)

-

((NUM(SUM({<Departament>}{<MONTH={$(=NUM($(=MAX({<ID_CLASS={$(Total_Cost)}>}MONTH)),'00'))}>} BENEFIT) /

       SUM({<Departament>}{<MONTH={$(=NUM($(=MAX({<ID_CLASS={$(Total_Cost)}>}MONTH)),'00'))}>} HOURS),'###.##0,00'))

))<0,1,0)

But I get the error: nested aggregation not allowed

Any idea? Thank you so much

1 Solution

Accepted Solutions
Highlighted

Re: Count condition error: nested aggregation not allowed

Try this

Sum(Aggr(

if(( AVG(STANDAR_COST)

-

((NUM(SUM({<MONTH={$(=NUM($(=MAX({<ID_CLASS={$(Total_Cost)}>}MONTH)),'00'))}>} BENEFIT) /

      SUM({<MONTH={$(=NUM($(=MAX({<ID_CLASS={$(Total_Cost)}>}MONTH)),'00'))}>} HOURS),'###.##0,00'))

))<0,1,0),

Departament))

View solution in original post

1 Reply
Highlighted

Re: Count condition error: nested aggregation not allowed

Try this

Sum(Aggr(

if(( AVG(STANDAR_COST)

-

((NUM(SUM({<MONTH={$(=NUM($(=MAX({<ID_CLASS={$(Total_Cost)}>}MONTH)),'00'))}>} BENEFIT) /

      SUM({<MONTH={$(=NUM($(=MAX({<ID_CLASS={$(Total_Cost)}>}MONTH)),'00'))}>} HOURS),'###.##0,00'))

))<0,1,0),

Departament))

View solution in original post