Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
fonsosurfer
Contributor
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
sunny_talwar

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
sunny_talwar

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))