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: 
karin_nevo
Contributor III
Contributor III

Count for last month in each year

Hi,

I have a table of Month, year and Employee ID.

I am trying to create a chart that for each displayed year, show the count of employees for the last month exists in that year (if no selections are made - it should show Dec of all previous years, and for current year - it should show Mar data.

My dimension is: Year

My expression is:

=Aggr(count({<HC_MonthNum={$(=max(Aggr(max(HC_MonthNum),HC_Year)))}>}distinct EMP_ID),HC_Year)

I get the correct result for previous years and no data for current year:

   

HC_Year#Emp
20170
2016200
2015300
2014400

the expected result is to show the number of employees in March for 2017 (this is the last month exists in the table for current year)

appriciate your assitance.

Thanks

16 Replies
karin_nevo
Contributor III
Contributor III
Author

Not exactly, I expect to see:

A, 2016, 2

A, 2017, 3

B, 2015,4

Others, 1

I expect to see the 2 divisions for all years when I limit Division dimension to 2.

sunny_talwar

Why does B, 2016, 2 is not shown?

karin_nevo
Contributor III
Contributor III
Author

because he has no data in Dec

sunny_talwar

Try this may be

karin_nevo
Contributor III
Contributor III
Author

Thanks for your help.

It works good for the test data, but when I try it on the real data, the QV document get stucked trying to calculate the expression.

sunny_talwar

Yes, this is going to be a resource intensive expression.. I have tried another approach, but don't think this is any better

karin_nevo
Contributor III
Contributor III
Author

I know, and this is not what I want. Is there any other way?