Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How can obtain an average ?

Hi all,

I have this file and I want to obtain for 2013 Average effective by service, so :

DIR COMM. = Sum(Janv+Fev+Mar+Avr+juin+Juil) / 7

SociétéServiceMoisAnnéeEffectifs
CORPADIR. COMM.janv.20133
CORPADIR. COMM.févr.20133
CORPADIR. COMM.mars20133
CORPADIR. COMM.avr.20132
CORPADIR. COMM.mai20132
CORPADIR. COMM.juin20132
CORPADIR. COMM.juil.20132
CORPADIR. PROJ.janv.20133
CORPADIR. PROJ.févr.20133
CORPADIR. PROJ.mars20133
CORPADIR. PROJ.avr.20139
CORPADIR. PROJ.mai20139
CORPADIR. PROJ.juin20139
CORPADIR. PROJ.juil.20139
CORPADIR. SUPP.avr.20131
CORPADIR. SUPP.mai20131
CORPADIR. SUPP.juin20131
CORPADIR. SUPP.juil.20131

Can someone has a simple expression ?

Thanks for your help.

1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

You have to have an aggregation function outside the aggr, too. And you don't need Société or Service as grouping symbols. Hence, one of the two following should work:

Sum( Effectifs ) / Count( distinct Mois )

Avg( Aggr( Sum( Effectifs ), Mois ) )

So, Swuehl's suggestion above is probably the best path forward.

HIC

View solution in original post

6 Replies
swuehl
MVP
MVP

Just create a chart with dimension service and then either

=avg(Effectivs)

if your effectivs are aggregated by month and you want to consider the number of months available, or maybe otherwise

=sum(Effectivs) / 7

Not applicable
Author

Thanks but if I have 12 months and not 7 How can have a simple dynamic calculation?

swuehl
MVP
MVP

Using the avg() function or

=sum(Effectifs) / count(distinct Mois)

hic
Former Employee
Former Employee

Not applicable
Author

Henric I try : (Aggr(Sum(Effectifs) / count( distinct Mois),Société,Service,Mois))

I obtain 3,6 but not 2,4.

hic
Former Employee
Former Employee

You have to have an aggregation function outside the aggr, too. And you don't need Société or Service as grouping symbols. Hence, one of the two following should work:

Sum( Effectifs ) / Count( distinct Mois )

Avg( Aggr( Sum( Effectifs ), Mois ) )

So, Swuehl's suggestion above is probably the best path forward.

HIC