Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

maxicarena
Contributor

Use Aggr function twice in calculation?

Hello community,

Can I use the Aggr function twice within the same calculation?

Ex: Avg(Aggr(Count(Aggr(If...,Field))))

Note: Message was edited by Community Moderator for clarity.

22 Replies
MVP
MVP

Re: Use Aggr function twice in calculation?

Yes, you can.

MVP
MVP

Re: Use Aggr function twice in calculation?

Depends on what you are trying to do. If you want to know if the syntax is allowed, yes it is. But what exactly do you need this for? May be share a sample with your expected output

maxicarena
Contributor

Re: Use Aggr function twice in calculation?

Ahh, I thought it was wrong and could not be used 2 times, as it gave me error, invalid function. I'll keep trying and if not inform you and explain the function and related fields.

Thanks you.

MVP
MVP

Re: Use Aggr function twice in calculation?

Maybe we can help you better if you post the full expression.

Advanced aggregation always shows a single expression and one or more dimension fields as arguments to aggr() function.

maxicarena
Contributor

Re: Use Aggr function twice in calculation?

Hi swuehl,

Step formula here where I have the inchoerencia: Avg (Aggr (Count (Aggr (If (Sum (VALO)> 0, DOC_CLI), DOC_CLI)) * COUNT (DISTINCT DATE))).

So yes I instead works: Count (Aggr (If (Sum (VALO)> 0, DOC_CLI), DOC_CLI)) * COUNT (DISTINCT DATE)

I need to average this.


This is why we consult them if they could include two Aggr, how can I fix it?

MVP
MVP

Re: Use Aggr function twice in calculation?

Have a look at

Average – Which average?

So, what is the internal grouping entity in your case?

maxicarena
Contributor

Re: Use Aggr function twice in calculation?

Hi Sunny, Step formula here where I have the inchoerencia: Avg (Aggr (Count (Aggr (If (Sum (VALO)> 0, DOC_CLI), DOC_CLI)) * COUNT (DISTINCT DATE))).

So yes I instead works: Count (Aggr (If (Sum (VALO)> 0, DOC_CLI), DOC_CLI)) * COUNT (DISTINCT DATE)

I need to average this.


This is why we consult them if they could include two Aggr, how can I fix it?

maxicarena
Contributor

Re: Use Aggr function twice in calculation?

I hope to be more explanatory, you can not clearly see the solution in the link you shared me.

Captura.PNG

MVP
MVP

Re: Use Aggr function twice in calculation?

How about this:

Sum(Aggr(Count(Aggr(If(Sum(VALO) > 0, DOC_CLI), DOC_CLI)) * Count(DISTINCT DATE), DOC_CLI))

or this:

Sum(Aggr(Count(Aggr(If(Sum(VALO) > 0, DOC_CLI), DOC_CLI, FECHA)) * Count(DISTINCT DATE), DOC_CLI))

Community Browser