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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
marley1978
Contributor III
Contributor III

Help with Aggr

I have searched on this topic and have not found a solution

I am trying to get an average of active employees by month and gender

My data looks like this

ReportMonthEmpIDActive FlagNew Hire FlagGender
01/2018110F
01/2018210F
01/2018301F
01/2018410M
01/2018501M
02/2018110F
02/2018200F
02/2018310F
02/2018400F
02/2018510M
02/2018601M
02/2018701M
02/2018801M

What I am trying to do is get the average  count of Active Flag + New Hire by month and gender.

I have this and this works by Month.

AVG(Aggr(count( {<ActiveFlag= {'1'}>} EmployeeID) + count( {< NewHireFlag= {'1'}>} EmployeeID), ReportMonth))

In my bar chart I have only gender as a dimension  but it doesn't do the calculations right.

My expected result based on the data above would look like this.

Average Female active employees for the both month = 2.5

Average Male active employees for both months = 3

Please help

1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

May be this

Avg(Aggr(Count({<[Active Flag]= {'1'}>+<[New Hire Flag] = {'1'}>} EmpID), ReportMonth, Gender))

View solution in original post

7 Replies
sunny_talwar
MVP
MVP

May be this

Avg(Aggr(Count({<[Active Flag]= {'1'}>+<[New Hire Flag] = {'1'}>} EmpID), ReportMonth, Gender))

marley1978
Contributor III
Contributor III
Author

Thank you so much.  It worked

Digvijay_Singh
MVP
MVP

I came up with this -

Aggr(nodistinct Avg(Aggr(Sum([Active Flag])+Sum([New Hire Flag]),Gender,ReportMonth)),Gender)

sunny_talwar
MVP
MVP

Why an extra Aggr()?

Digvijay_Singh
MVP
MVP

When Chart dimension is Only Gender,then it wasn't working, showing '-'. Worked when surrounded by extra aggr.

sunny_talwar
MVP
MVP

Seems to be working for me in QlikView

Capture.PNG

Did you try in View or Sense?

Digvijay_Singh
MVP
MVP

My bad, may be I had something else when I saw '-' - both works in sense too -

Capture.PNG