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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculating values for each year/month from a Start Date

I have an HR application which provides a contract start date for each employee. I need to be able to show how many people are employed by the company by year/month from some date in the past to the current date.

Is there a way of doing this within QV (version 9 - personal edition)?

3 Replies
Not applicable
Author

Hi logan,

Here you are a possible solution. I hope it would help you.

You can check out the results making a table on the Total_Emp data.

Regards.


Contract:
LOAD * INLINE [
Date, Employee
01/01/2009, E1
01/01/2009, E2
15/01/2009, E3
20/02/2009, E4
06/06/2009, E1
10/12/2009, E5
02/04/2010, E6
];
Calendar:
Load Distinct Year(Date) & '-' & Month(Date) as YM,
Date
Resident Contract;
Total_Emp:
Load Year(Date) & '-' & Month(Date) as YM,
Count(Employee) as TotalEmp
Resident Contract
group by Year(Date) & '-' & Month(Date);


johnw
Champion III
Champion III

One approach is to actually create a record for every month the employee was employed. Here's an example (untested, and I'm assuming contracts can have ending dates as well):

[Employeess vs. Months]:
LOAD
"Employee"
,addmonths("Hire Month",iterno()-1) as "Month of Employment"
RESIDENT [Employees]
WHILE addmonths("Hire Month",iterno()-1) <= "Fire Month"
;

Chart:

Dimension = Month of Employment
Expression = count(distinct Employee)

You might also want to look at the intervalmatch() function for the same basic idea, just done differently.

Not applicable
Author

Hi there, you can use set analysis to limit artificially select a range of date. Your expressión might look some like this:

count({$<MonthYear = {">=PastMonthYear<=CurrentMonthYear"}>} EmployeeID)

That should do the trick.

Regards