Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
swuehl
MVP
MVP

Yes, you can.

sunny_talwar

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

Anonymous
Not applicable
Author

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.

swuehl
MVP
MVP

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.

Anonymous
Not applicable
Author

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?

swuehl
MVP
MVP

Have a look at

Average – Which average?

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

Anonymous
Not applicable
Author

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?

Anonymous
Not applicable
Author

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

Captura.PNG

sunny_talwar

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